S60 3rd Edition SDK for Symbian OS
Example Applications Guide

EnvMappingContainer.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : EnvMappingContainer.h
00004 *  Part of     : OpenGLEx / EnvMapping
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 ENVMAPPINGCONTAINER_H
00017 #define ENVMAPPINGCONTAINER_H
00018 
00019 // INCLUDES
00020 #include <coecntrl.h>
00021 #include <GLES/egl.h>         // EGL header file
00022 #include "EnvMappingAppUi.h"   
00023 #include "EnvMapping.h"       // Main OpenGL ES class
00024 #include <akndef.h>
00025 
00026 // CLASS DECLARATION
00027 
00028 /**
00029  * Container control class that handles the OpenGL ES initialization and deinitializations.
00030  * Also uses the CEnvMapping class to do the actual OpenGL ES rendering.
00031  */
00032 class CEnvMappingContainer : 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, CEnvMapping and uninitializes OpenGL ES.
00044          */
00045         virtual ~CEnvMappingContainer();
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 CEnvMapping to do the rendering for each frame.
00052          *@param aInstance Pointer to this instance of CEnvMappingContainer.
00053          */
00054         static int 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          * Method from CoeControl. Does nothing in this implementation.
00077          */
00078         TInt CountComponentControls() const;
00079 
00080         /**
00081          * Method from CCoeControl. Does nothing in this implementation.
00082          */
00083         CCoeControl* ComponentControl(TInt aIndex) const;
00084 
00085         /**
00086          * Method from CCoeControl. Does nothing in this implementation.
00087          * All rendering is done in the DrawCallBack() method.
00088          */
00089         void Draw(const TRect& aRect) const;
00090 
00091         /**
00092          * Method from MCoeControlObserver that handles an event from the observed control.
00093          * Does nothing in this implementation.
00094                  * @param aControl   Control changing its state.
00095                  * @param aEventType Type of the control event.
00096          */
00097         void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
00098         
00099     private: //data
00100 
00101         /** Display where the OpenGL ES window surface resides. */
00102         EGLDisplay        iEglDisplay;  
00103 
00104         /** Window surface where the OpenGL ES rendering is blitted to. */
00105         EGLSurface        iEglSurface;  
00106 
00107         /** OpenGL ES rendering context. */
00108         EGLContext        iEglContext;  
00109 
00110         /** Frame counter variable, used in the animation. */
00111         TInt              iFrame;                
00112 
00113         /** Active object that is the timing source for the animation. */
00114         CPeriodic*        iPeriodic; 
00115 
00116         /**
00117          * Flag that indicates if OpenGL ES has been initialized or not.
00118          * Used to check if SizeChanged() can react to incoming notifications.
00119          */
00120         TBool iOpenGlInitialized;
00121 
00122     public:  //data
00123 
00124         /** Used in DrawCallBack() method to do the actual OpenGL ES rendering.  */
00125         CEnvMapping*      iEnvMapping;
00126     };
00127 
00128 #endif
00129 
00130 // End of File

© Nokia 2006

Back to top