|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : Particles.h 00004 * Part of : OpenGLEx / Particles 00005 * 00006 * Copyright (c) 2005-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 __PARTICLESH__ 00014 #define __PARTICLESH__ 00015 00016 // INCLUDES 00017 00018 #include <e32base.h> // for CBase definition 00019 #include <GLES\gl.h> // OpenGL ES header file 00020 #include "Textureutils.h" 00021 #include "Mathutils.h" 00022 #include "Utils3d.h" 00023 00024 // FORWARD DECLARATIONS 00025 00026 /** 00027 * Class that does the actual OpenGL ES rendering. 00028 * Subclass of CFiniteStateMachine because the application 00029 * needs to handle loading textures and running states. 00030 */ 00031 class CParticles 00032 : public CFiniteStateMachine, public MTextureLoadingListener 00033 { 00034 public: // Constructors and destructor 00035 00036 /** 00037 * Factory method for creating a new CParticles object. 00038 * Calls the hidden constructors. 00039 */ 00040 static CParticles* NewL( TUint aWidth, TUint aHeight, TUint aParticleCount = 64 ); 00041 00042 /** 00043 * Destructor. Does nothing. 00044 */ 00045 virtual ~CParticles(); 00046 00047 protected: // Hidden constructors 00048 00049 /** 00050 * Standard constructor that must never Leave. 00051 * Stores the given screen width and height. 00052 * @param aWidth Width of the screen. 00053 * @param aHeight Height of the screen. 00054 * @param aParticleCount Particle count. 00055 */ 00056 CParticles( TUint aWidth, TUint aHeight, TUint aParticleCount ); 00057 00058 /** 00059 * Second phase constructor that can call methods that may leave. Does nothing. 00060 */ 00061 void ConstructL( void ); 00062 00063 00064 public: // New methods 00065 00066 /** 00067 * Initializes OpenGL ES, sets the vertex and color 00068 * arrays and pointers. Also selects the shading mode and 00069 * creates the CTextureManager instance and starts loading 00070 * of required textures. 00071 */ 00072 void AppInitL( void ); 00073 00074 /** 00075 * Called upon application exit. Destroys the CTextureManager 00076 * instance that was created in AppInitL() method. 00077 */ 00078 void AppExit( void ); 00079 00080 /** 00081 * Renders one frame. 00082 * @param aFrame Number of the frame to be rendered. 00083 * @param aTimeSecs Seconds elapsed since the application started running. 00084 * @param aDeltaTimeSecs Seconds elapsed since last call to AppCycle(). 00085 */ 00086 void AppCycle( TInt aFrame, TReal aTimeSecs, TReal aDeltaTimeSecs ); 00087 00088 /** 00089 * Called when the finite state machine enters a new state. 00090 * Does nothing in this implementation. 00091 * @param aState State that is about to be entered. 00092 */ 00093 void OnEnterStateL( TInt aState); 00094 00095 /** 00096 * Called when texture manager starts loading the textures. 00097 * Sets the current state to "loading textures". 00098 */ 00099 void OnStartLoadingTexturesL(); 00100 00101 /** 00102 * Called when texture manager has completed texture loading. 00103 * Changes the current state to "running". 00104 */ 00105 void OnEndLoadingTexturesL(); 00106 00107 /** 00108 * Notifies that the screen size has dynamically changed during execution of 00109 * this program. Resets the viewport to this new size and sets this size 00110 * to the CTextureManager. 00111 * @param aWidth New width of the screen. 00112 * @param aHeight New height of the screen. 00113 */ 00114 void SetScreenSize( TUint aWidth, TUint aHeight ); 00115 00116 public: // Data 00117 /** 00118 * Application states: 00119 * ELoadingTextures - indicates that the app. is loading textures. 00120 * ERunning - indicates that the app. is running. 00121 */ 00122 enum 00123 { 00124 ELoadingTextures, 00125 ERunning 00126 }; 00127 00128 private: // Methods 00129 /** 00130 * Animate the particles. 00131 * @param aTime Animation time parameter (seconds). 00132 */ 00133 void UpdateParticles( TReal aTime ); 00134 00135 /** 00136 * Draw the particles. 00137 */ 00138 void DrawParticles( TReal aTime ); 00139 00140 /** 00141 * Draw a feedback effect. 00142 * @param aTime Animation time parameter (seconds). 00143 */ 00144 void DrawFeedbackEffect( TReal aTime ); 00145 00146 /** 00147 * Update the feedback effect based on the contents of the framebuffer. 00148 */ 00149 void UpdateFeedbackEffect(); 00150 00151 private: // Data 00152 00153 /** Texture manager that is used to load the used textures. */ 00154 CTextureManager *iTextureManager; 00155 /** Width of the screen */ 00156 TUint iScreenWidth; 00157 /** Height of the screen */ 00158 TUint iScreenHeight; 00159 /** Camera. */ 00160 TCamera iCamera; 00161 /** Particle texture */ 00162 TTexture iParticleTexture; 00163 /** Particle count */ 00164 TUint iParticleCount; 00165 /** Particle coordinates */ 00166 GLfixed *iParticleCoords; 00167 /** Particle colors */ 00168 GLfixed *iParticleColors; 00169 /** Feedback texture handle */ 00170 GLuint iFeedbackTextureID; 00171 /** Feedback texture width */ 00172 TInt iFeedbackTextureWidth; 00173 /** Feedback texture height */ 00174 TInt iFeedbackTextureHeight; 00175 }; 00176 00177 #endif 00178 00179 // End of File 00180
|
© Nokia 2009 |