S60 3rd Edition SDK for Symbian OS
Example Applications Guide

SimpleLight.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : SimpleLight.h
00004 *  Part of     : OpenGLEx / SimpleLight
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 SIMPLELIGHT_H
00017 #define SIMPLELIGHT_H
00018 
00019 // INCLUDES
00020 #include <e32base.h> // for CBase definition
00021 #include <GLES/gl.h> // OpenGL ES header file
00022 
00023 /** Enumerated value that is used to switch between duck and head models. */
00024 typedef enum { EDuckModel, EHeadModel } TUsedModel;
00025 
00026 // MACROS
00027 #define FRUSTUM_LEFT   -1.f     //left vertical clipping plane
00028 #define FRUSTUM_RIGHT   1.f     //right vertical clipping plane
00029 #define FRUSTUM_BOTTOM -1.f     //bottom horizontal clipping plane
00030 #define FRUSTUM_TOP     1.f     //top horizontal clipping plane
00031 #define FRUSTUM_NEAR    3.f     //near depth clipping plane
00032 #define FRUSTUM_FAR  1000.f     //far depth clipping plane
00033 
00034 // CLASS DECLARATION
00035 
00036 /**
00037  * Class that does the actual OpenGL ES rendering.
00038  */
00039 class CSimpleLight : public CBase
00040     {
00041     public:  // Constructors and destructor
00042 
00043         /**
00044          * Factory method for creating a new CSimpleCube object.
00045          */
00046         static CSimpleLight* NewL( TUint aWidth, TUint aHeight);
00047 
00048         /**
00049          * Destructor. Does nothing.
00050          */
00051         virtual ~CSimpleLight();
00052 
00053     public:  // New functions
00054     
00055         /**
00056          * Initializes OpenGL ES, sets the vertex and color
00057          * arrays and pointers. Also selects the shading mode.
00058          */
00059         void AppInit( void );
00060 
00061         /**
00062          * Called upon application exit. Does nothing.
00063          */
00064         void AppExit( void );
00065 
00066         /**
00067          * Renders one frame.
00068          * @param aFrame Number of the frame to be rendered.
00069          */
00070         void AppCycle( TInt aFrame );
00071 
00072         /**
00073          * Toggles lighting enabled/disabled.
00074          */
00075         void ToggleLighting( void );
00076         
00077         /**
00078          * Toggles lamp enabled/disabled.
00079          */
00080         void ToggleLamp( void );
00081         
00082         /**
00083          * Toggles spot light enabled/disabled.
00084          */
00085         void ToggleSpot( void );
00086         
00087         /**
00088          * Changes the current model to duck object.
00089          */
00090         void DuckModel( void );
00091         
00092         /**
00093          * Changes the current model to head object.
00094          */
00095         void HeadModel( void );
00096 
00097         /**
00098          * Notifies that the screen size has dynamically changed during execution of
00099          * this program. Resets the viewport to this new size.
00100          * @param aWidth New width of the screen.
00101          * @param aHeight New height of the screen.
00102          */
00103         void SetScreenSize( TUint aWidth, TUint aHeight );
00104 
00105     protected: // New functions
00106 
00107         /**
00108          * Standard constructor that must never Leave.
00109          * Stores the given screen width and height.
00110          * @param aWidth Width of the screen.
00111          * @param aHeight Height of the screen.
00112          */
00113         CSimpleLight( TUint aWidth, TUint aHeight );
00114 
00115         /**
00116          * Second phase contructor. Does nothing.
00117          */
00118         void ConstructL( void );
00119     
00120         /**
00121          * Helper function that is used to make the duck 'quak'.
00122          * Calculates the sine for the given angle. Returns 0 if any
00123          * errors occur while calling the Math::Sin() method.
00124          * @param aRad Radian angle whose sine is to be calculated.
00125          * @return The sine of the given angle or 0 if error occured while calculating the sine.
00126          */
00127         GLfloat sin( GLfloat aRad );
00128         
00129     public: // Data
00130 
00131         /** Whether or not the lighting is enabled. Used when building the menu for the application. */
00132         TBool iLightingEnabled;
00133 
00134         /** Whether or not the lamp is enabled. Used when building the menu for the application. */
00135         TBool iLampEnabled;
00136 
00137         /** Whether or not the spotlight is enabled. Used when building the menu for the application. */
00138         TBool iSpotEnabled;     
00139         
00140     private: // Data
00141 
00142         /** Width of the screen */
00143         TUint iScreenWidth;
00144 
00145         /** Height of the screen */
00146         TUint iScreenHeight;
00147 
00148         /** Enumerated value for switching between the HEAD and DUCK model. */
00149         TUsedModel iObjectModel; 
00150     };
00151 
00152 #endif // SIMPLELIGHT_H

© Nokia 2006

Back to top