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