S60 3rd Edition SDK for Symbian OS
Example Applications Guide

SimpleCubePixmapContainer.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : SimpleCubePixmapContainer.h
00004 *  Part of     : OpenGLEx / SimpleCubePixmap
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 SIMPLECUBEPIXMAPCONTAINER_H
00017 #define SIMPLECUBEPIXMAPCONTAINER_H
00018 
00019 // INCLUDES
00020 #include <coecntrl.h>
00021 #include <GLES/egl.h>
00022 #include <akndef.h>
00023 #include "SimpleCubePixmap.h"
00024 
00025 // CLASS DECLARATION
00026 
00027 /**
00028  * Container control class that handles the OpenGL ES initialization and deinitializations.
00029  * Also uses the CSimpleCubePixmap class to do the actual OpenGL ES rendering.
00030  */
00031 class CSimpleCubePixmapContainer : 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, CSimpleCubePixmap and uninitializes OpenGL ES.
00043          */
00044         virtual ~CSimpleCubePixmapContainer();
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 CSimpleCubePixmap to do the rendering for each frame.
00051          *@param aInstance Pointer to this instance of CSimpleCubePixmapContainer.
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 
00103         /** Describes the format, type and size of the color buffers and ancillary buffers for EGLSurface. */
00104         EGLConfig iConfig;                        
00105         
00106         /** The bitmap where the framebuffer is drawn. */
00107         CWsBitmap*  iPixmap;
00108 
00109         /** Pixmap surface (that uses the iPixmap) that is the target of OpenGL ES graphics rendering. */
00110         EGLSurface  iEglSurface;  
00111 
00112         /** OpenGL ES rendering context. */
00113         EGLContext  iEglContext;
00114         
00115         /** Active object that is the timing source for the animation. */
00116         CPeriodic*  iPeriodic;    
00117 
00118         /**
00119          * Flag that indicates if OpenGL ES has been initialized or not.
00120          * Used to check if SizeChanged() can react to incoming notifications.
00121          */
00122         TBool iOpenGlInitialized;
00123         
00124     public:  //data
00125 
00126         /** Frame counter variable, used in the animation. */
00127         TInt iFrame;             
00128 
00129         /** Used in DrawCallBack() method to do the actual OpenGL ES rendering.  */
00130         CSimpleCubePixmap* iSimpleCubePixmap; 
00131     };
00132 
00133 #endif
00134 
00135 // End of File

© Nokia 2006

Back to top