S60 3rd Edition SDK for Symbian OS
Example Applications Guide

Shadows.h

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

© Nokia 2006

Back to top