|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : Shadows.h 00004 * Part of : OpenGLEx / Shadows 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 SHADOWS_H 00014 #define SHADOWS_H 00015 00016 00017 // INCLUDES 00018 #include <e32base.h> // for CBase definition 00019 #include <GLES/gl.h> // OpenGL ES header file 00020 #include "glutils.h" // Misc GLU and GLUT functions 00021 00022 // MACROS 00023 #define FRUSTUM_LEFT -1.f //left vertical clipping plane 00024 #define FRUSTUM_RIGHT 1.f //right vertical clipping plane 00025 #define FRUSTUM_BOTTOM -1.f //bottom horizontal clipping plane 00026 #define FRUSTUM_TOP 1.f //top horizontal clipping plane 00027 #define FRUSTUM_NEAR 3.f //near depth clipping plane 00028 #define FRUSTUM_FAR 1000.f //far depth clipping plane 00029 00030 // CLASS DECLARATION 00031 00032 /** 00033 * Class that does the actual OpenGL ES rendering. 00034 */ 00035 class CShadows : public CBase 00036 { 00037 public: // Constructors and destructor 00038 00039 /** 00040 * Factory method for creating a new CShadows object. 00041 */ 00042 static CShadows* NewL( TUint aWidth, TUint aHeight); 00043 00044 /** 00045 * Destructor. Does nothing. 00046 */ 00047 virtual ~CShadows(); 00048 00049 public: // New functions 00050 00051 /** 00052 * Initializes OpenGL ES, sets the vertex and color 00053 * arrays and pointers. Also selects the shading mode. 00054 */ 00055 void AppInit( void ); 00056 00057 /** 00058 * Called upon application exit. Does nothing. 00059 */ 00060 void AppExit( void ); 00061 00062 /** 00063 * Draws the ground plane. 00064 */ 00065 void DrawPlane( void ); 00066 00067 /** 00068 * Draws the lamp. 00069 */ 00070 void DrawLamp( void ); 00071 00072 /** 00073 * Draws the shadows. 00074 */ 00075 void DrawShadowObject( void ); 00076 00077 /** 00078 * Draw the object. 00079 */ 00080 void DrawObject( void ); 00081 00082 /** 00083 * Calculate proper shadow matrix. 00084 */ 00085 void CalculateProjectionMatrix( void ); 00086 00087 /** 00088 * Renders one frame. 00089 * @param aFrame Number of the frame to be rendered. 00090 */ 00091 void AppCycle( TInt aFrame ); 00092 00093 /** 00094 * Rotates light to left 00095 */ 00096 void RotateLightLeft( void ); 00097 00098 /** 00099 * Rotates light to right 00100 */ 00101 void RotateLightRight( void ); 00102 00103 /** 00104 * Notifies that the screen size has dynamically changed during execution of 00105 * this program. Resets the viewport to this new size. 00106 * @param aWidth New width of the screen. 00107 * @param aHeight New height of the screen. 00108 */ 00109 void SetScreenSize( TUint aWidth, TUint aHeight ); 00110 00111 protected: // New functions 00112 00113 /** 00114 * Standard constructor that must never Leave. 00115 * Stores the given screen width and height. 00116 * @param aWidth Width of the screen. 00117 * @param aHeight Height of the screen. 00118 */ 00119 CShadows( TUint aWidth, TUint aHeight); 00120 00121 /** 00122 * Second phase contructor. Does nothing. 00123 */ 00124 void ConstructL( void ); 00125 00126 private: // Data 00127 00128 /** Width of the screen */ 00129 TUint iScreenWidth; 00130 00131 /** Height of the screen */ 00132 TUint iScreenHeight; 00133 00134 00135 /** Radius of the light. */ 00136 GLfloat iLightRadius; 00137 00138 /** Angle of the light. */ 00139 GLfloat iLightAngle; 00140 00141 00142 /** X coordinate of the light */ 00143 GLfloat iLightPosX; 00144 00145 /** Y coordinate of the light */ 00146 GLfloat iLightPosY; 00147 00148 /** Z coordinate of the light */ 00149 GLfloat iLightPosZ; 00150 00151 00152 /** Light position. */ 00153 GLfloat iLightPos[4]; 00154 00155 /** Shadow projection matrix. */ 00156 GLfloat iShadowMat[16]; 00157 00158 00159 /** Whether the light is rotated left each frame or not. */ 00160 TBool iIsLightRotatedLeft; 00161 00162 /** Whether the light is rotated right each frame or not. */ 00163 TBool iIsLightRotatedRight; 00164 00165 }; 00166 00167 00168 #endif 00169 // End of File
|
© Nokia 2009 |