S60 3rd Edition SDK FP1 for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : SimpleCube.h 00004 * Part of : OpenGLEx / SimpleCube 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 SIMPLECUBE_H 00014 #define SIMPLECUBE_H 00015 00016 // INCLUDES 00017 #include <e32base.h> // for CBase definition 00018 #include <GLES/gl.h> // OpenGL ES header file 00019 00020 /** Enumerated rendering mode for triangle and triangle fan based rendering. */ 00021 typedef enum { ETriangles, ETriangleFans } TRenderingMode; 00022 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 CSimpleCube : public CBase 00038 { 00039 public: // Constructors and destructor 00040 00041 /** 00042 * Factory method for creating a new CSimpleCube object. 00043 */ 00044 static CSimpleCube* NewL( TUint aWidth, TUint aHeight); 00045 00046 /** 00047 * Destructor. Does nothing. 00048 */ 00049 virtual ~CSimpleCube(); 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 a 3D box with triangles or triangle fans depending 00066 * on the current rendering mode.Scales the box to the given size using glScalef. 00067 * @param aSizeX X-size of the box. 00068 * @param aSizeY Y-size of the box. 00069 * @param aSizeZ Z-size of the box. 00070 */ 00071 void DrawBox( GLfloat aSizeX, GLfloat aSizeY, GLfloat aSizeZ ); 00072 00073 /** 00074 * Renders one frame. 00075 * @param aFrame Number of the frame to be rendered. 00076 */ 00077 void AppCycle( TInt aFrame ); 00078 00079 /** 00080 * Sets the shading mode to flat. 00081 */ 00082 void FlatShading( void ); 00083 00084 /** 00085 * Sets the shading to smooth (gradient). 00086 */ 00087 void SmoothShading( void ); 00088 00089 /** 00090 * Sets the rendering to use triangles. 00091 */ 00092 void TriangleMode( void ); 00093 00094 /** 00095 * Sets the rendering to use triangle fans. 00096 */ 00097 void TriangleFanMode( void ); 00098 00099 /** 00100 * Notifies that the screen size has dynamically changed during execution of 00101 * this program. Resets the viewport to this new size. 00102 * @param aWidth New width of the screen. 00103 * @param aHeight New height of the screen. 00104 */ 00105 void SetScreenSize( TUint aWidth, TUint aHeight ); 00106 00107 protected: // New functions 00108 00109 /** 00110 * Standard constructor that must never Leave. 00111 * Stores the given screen width and height. 00112 * @param aWidth Width of the screen. 00113 * @param aHeight Height of the screen. 00114 */ 00115 CSimpleCube( TUint aWidth, TUint aHeight); 00116 00117 /** 00118 * Second phase contructor. Does nothing. 00119 */ 00120 void ConstructL( void ); 00121 00122 private: // Data 00123 00124 /** Width of the screen */ 00125 TUint iScreenWidth; 00126 00127 /** Height of the screen */ 00128 TUint iScreenHeight; 00129 00130 /** The current rendering mode */ 00131 TRenderingMode iDrawingMode; 00132 }; 00133 #endif // SIMPLECUBE_H 00134 00135 // End of File
© Nokia 2006 |