|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : MultiTex.h 00004 * Part of : OpenGLEx / MultiTex 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 MULTITEX_H 00014 #define MULTITEX_H 00015 00016 // INCLUDES 00017 #include <e32base.h> // for CBase definition 00018 #include <GLES/gl.h> // OpenGL ES header file 00019 #include <GLES/egl.h> // OpenGL ES header file 00020 #include "Utils3d.h" // Utilities (state machine, texture manager etc.) 00021 #include "Glutils.h" // Misc GLU and GLUT functions 00022 00023 // MACROS 00024 #define FRUSTUM_LEFT -1.f //left vertical clipping plane 00025 #define FRUSTUM_RIGHT 1.f //right vertical clipping plane 00026 #define FRUSTUM_BOTTOM -1.f //bottom horizontal clipping plane 00027 #define FRUSTUM_TOP 1.f //top horizontal clipping plane 00028 #define FRUSTUM_NEAR 3.f //near depth clipping plane 00029 #define FRUSTUM_FAR 1000.f //far depth clipping plane 00030 00031 // CLASS DECLARATION 00032 00033 /** 00034 * Class that does the actual OpenGL ES rendering. 00035 * Subclass of CFiniteStateMachine because the application 00036 * needs to handle loading textures and running states. 00037 */ 00038 class CMultiTex : public CFiniteStateMachine, public MTextureLoadingListener 00039 { 00040 public: // Constructors and destructor 00041 00042 /** 00043 * Factory method for creating a new CMultiTex object. 00044 */ 00045 static CMultiTex* NewL( TUint aWidth, TUint aHeight); 00046 00047 /** 00048 * Destructor. Does nothing. 00049 */ 00050 virtual ~CMultiTex(); 00051 00052 public: // New functions 00053 00054 /** 00055 * Initializes OpenGL ES, sets the vertex and color 00056 * arrays and pointers. Also selects the shading mode and 00057 * creates the CTextureManager instance and starts loading 00058 * of required textures. 00059 */ 00060 void AppInitL( TAny* aInstance ); 00061 00062 /** 00063 * Called upon application exit. Destroys the CTextureManager 00064 * instance that was created in AppInitL() method. 00065 */ 00066 void AppExit( void ); 00067 00068 /** 00069 * Renders one frame with Pbuffer context to Ppbuffer surface. 00070 * @param aFrame Number of the frame to be rendered. 00071 */ 00072 void AppCyclePbuffer( TInt aFrame ); 00073 00074 /** 00075 * Renders one frame with Window context to Window surface. 00076 * @param aFrame Number of the frame to be rendered. 00077 */ 00078 void AppCycleWindow( TInt aFrame ); 00079 00080 /** 00081 * Called when the finite state machine enters a new state. 00082 * Does nothing in this implementation. 00083 * @param aState State that is about to be entered. 00084 */ 00085 void OnEnterStateL( TInt aState ); 00086 00087 /** 00088 * Called when texture manager starts loading the textures. 00089 * Sets the current state to "loading textures". 00090 */ 00091 void OnStartLoadingTexturesL(); 00092 00093 /** 00094 * Called when texture manager has completed texture loading. 00095 * Changes the current state to "running". 00096 */ 00097 void OnEndLoadingTexturesL(); 00098 00099 /** 00100 * Calculate light texture for environment map lights. 00101 */ 00102 void CalculateLightsL( void ); 00103 00104 /** 00105 * Draws lights with given dimensions. 00106 * @param iFrame The current frame number 00107 */ 00108 void DrawLights( TInt iFrame ); 00109 00110 /** 00111 * Notifies that the screen size has dynamically changed during execution of 00112 * this program. Resets the viewport to this new size and sets this size 00113 * to the CTextureManager. 00114 * @param aWidth New width of the screen. 00115 * @param aHeight New height of the screen. 00116 */ 00117 void SetScreenSize( TUint aWidth, TUint aHeight ); 00118 00119 protected: // New functions 00120 00121 /** 00122 * Standard constructor that must never Leave. 00123 * Stores the given screen width and height. 00124 * @param aWidth Width of the screen. 00125 * @param aHeight Height of the screen. 00126 */ 00127 CMultiTex( TUint aWidth, TUint aHeight); 00128 00129 /** 00130 * Second phase contructor. Does nothing. 00131 */ 00132 void ConstructL( void ); 00133 00134 public: // Data 00135 00136 /** 00137 * Application states: 00138 * ELoadingTextures - indicates that the app. is loading textures. 00139 * ERunning - indicates that the app. is running. 00140 */ 00141 enum 00142 { 00143 ELoadingTextures, 00144 ERunning 00145 }; 00146 00147 00148 private: // Data 00149 00150 /** Texture manager that is used to load the used textures. */ 00151 CTextureManager * iTextureManager; 00152 /** Width of the screen */ 00153 TUint iScreenWidth; 00154 /** Height of the screen */ 00155 TUint iScreenHeight; 00156 /** Aspect ratio of the screen (iScreenHeight / iScreenWidth). */ 00157 GLfloat iAspectRatio; 00158 00159 /** World texture. */ 00160 TTexture iWorldTexture; 00161 /** Pointer to the light texture data. */ 00162 TUint8* iLightTex; 00163 /** List for light and env map texture objects. */ 00164 GLuint iLightTexObjects[2]; 00165 }; 00166 #endif // MULTITEX_H 00167 00168 // End of File
|
© Nokia 2009 |