Nokia N97 SDK
Example Applications Guide

EnvMappingContainer.h

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

© Nokia 2009

Back to top