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