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