Nokia N97 SDK
Example Applications Guide

SimpleCubePbufferContainer.h

00001 /*
00002  * ==============================================================================
00003  *  Name        : SimpleCubePbufferContainer.h
00004  *  Part of     : OpenGLEx / SimpleCubePbuffer
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 SIMPLECUBEPBUFFERCONTAINER_H
00014 #define SIMPLECUBEPBUFFERCONTAINER_H
00015 
00016 // INCLUDES
00017 #include <coecntrl.h>
00018 #include <GLES/egl.h>
00019 #include <akndef.h>
00020 #include <aknappui.h> 
00021 #include "SimpleCubePbuffer.h"
00022 
00023 // CLASS DECLARATION
00024 
00025 /**
00026  * Container control class that handles the OpenGL ES initialization and deinitializations.
00027  * Also uses the CSimpleCubePbuffer class to do the actual OpenGL ES rendering.
00028  */
00029 class CSimpleCubePbufferContainer : public CCoeControl, MCoeControlObserver
00030     {
00031     public: // Constructors and destructor
00032 
00033         /**
00034          * EPOC default constructor. Initializes the OpenGL ES for rendering to the PBuffer surface.
00035          * @param aRect Screen rectangle for container.
00036          */
00037         void ConstructL(const TRect& aRect, CAknAppUi* aAppUi);
00038 
00039         /**
00040          * Destructor. Destroys the CPeriodic, CSimpleCubePbuffer and uninitializes OpenGL ES.
00041          */
00042         virtual ~CSimpleCubePbufferContainer();
00043 
00044     public: // New functions
00045 
00046         /**
00047          * Callback function for the CPeriodic. Calculates the current frame, keeps the background
00048          * light from turning off and orders the CSimpleCubePbuffer to do the rendering for each frame.
00049          *@param aInstance Pointer to this instance of CSimpleCubePbufferContainer.
00050          */
00051         static TInt DrawCallBack( TAny* aInstance );
00052 
00053     private: // Functions from base classes
00054 
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         /**
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 surface resides. */
00101         EGLDisplay  iEglDisplay;
00102 
00103         /** PBuffer surface that is the target of OpenGL ES graphics rendering. */
00104         EGLSurface  iEglSurface;
00105 
00106         /** Describes the format, type and size of the color buffers and ancillary buffers for EGLSurface. */
00107         EGLConfig iConfig;
00108 
00109         /** OpenGL ES rendering context. */
00110         EGLContext  iEglContext;
00111 
00112         /** Active object that is the timing source for the animation. */
00113         CPeriodic*  iPeriodic;
00114 
00115         // A bitmap where the framebuffer is drawn
00116         CWsBitmap*  iPixmap;
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 /** Application UI class for querying the client rectangle size. */ 
00125         CAknAppUi* iAppUi;
00126 
00127     public:  //data
00128 
00129         /** Frame counter variable, used in the animation. */
00130         TInt iFrame;
00131 
00132         /** Used in DrawCallBack() method to do the actual OpenGL ES rendering.  */
00133         CSimpleCubePbuffer* iSimpleCubePbuffer;
00134     };
00135 
00136 #endif
00137 
00138 // End of File

© Nokia 2009

Back to top