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