Nokia N97 SDK
Example Applications Guide

MultiTexContainer.h

00001 /*
00002  * ==============================================================================
00003  *  Name        : MultiTexContainer.h
00004  *  Part of     : OpenGLEx / MultiTex
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 MULTITEXCONTAINER_H
00014 #define MULTITEXCONTAINER_H
00015 
00016 // INCLUDES
00017 #include <coecntrl.h>
00018 #include <GLES/egl.h>
00019 #include "MultiTexAppUi.h"
00020 #include "MultiTex.h"
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 CMultiTex class to do the actual OpenGL ES rendering.
00029  */
00030 class CMultiTexContainer : public CCoeControl, MCoeControlObserver
00031     {
00032     public: // Constructors and destructor
00033 
00034         /**
00035         * EPOC default constructor.
00036         * @param aRect Frame rectangle for container.
00037         */
00038         void ConstructL(const TRect& aRect, CAknAppUi* aAppUi);
00039 
00040         /**
00041          * Destructor. Destroys the CPeriodic, CMultiTex and uninitializes OpenGL ES.
00042          */
00043         virtual ~CMultiTexContainer();
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 CMultiTex to do the rendering for each frame.
00050          *@param aInstance Pointer to this instance of CMultiTexContainer.
00051          */
00052         static TInt 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     public: //data
00098 
00099         /** Display where the OpenGL ES window surface resides. */
00100         EGLDisplay     iEglDisplay;
00101 
00102         /** Window context. */
00103         EGLSurface     iEglContext;
00104 
00105         /** Pbuffer context. */
00106         EGLContext  iEglPbufferContext;
00107 
00108         /** Window surface. */
00109         EGLSurface     iEglSurface;
00110 
00111         /** The Pbuffer where the graphics are drawn. */
00112         EGLSurface  iEglPbufferSurface;
00113 
00114         /** Frame counter variable, used in the animation. */
00115                 TInt iFrame;
00116 
00117         /** Active object that is the timing source for the animation. */
00118         CPeriodic*     iPeriodic;
00119 
00120         /** Used in DrawCallBack() method to do the actual OpenGL ES rendering.  */
00121         CMultiTex* iMultiTex;
00122 
00123 /** Application UI class for querying the client rectangle size. */ 
00124         CAknAppUi* iAppUi;
00125 
00126     private: //data
00127 
00128         /**
00129          * Flag that indicates if OpenGL ES has been initialized or not.
00130          * Used to check if SizeChanged() can react to incoming notifications.
00131          */
00132         TBool iOpenGlInitialized;
00133     };
00134 
00135 #endif
00136 
00137 // End of File

© Nokia 2009

Back to top