S60 3rd Edition SDK FP1 for Symbian OS Example Applications Guide |
#include <SimpleCube.h>
Inherits CBase.
Inheritance diagram for CSimpleCube:
Definition at line 37 of file SimpleCube.h.
Public Member Functions | |
virtual | ~CSimpleCube () |
void | AppInit (void) |
void | AppExit (void) |
void | DrawBox (GLfloat aSizeX, GLfloat aSizeY, GLfloat aSizeZ) |
void | AppCycle (TInt aFrame) |
void | FlatShading (void) |
void | SmoothShading (void) |
void | TriangleMode (void) |
void | TriangleFanMode (void) |
void | SetScreenSize (TUint aWidth, TUint aHeight) |
Static Public Member Functions | |
static CSimpleCube * | NewL (TUint aWidth, TUint aHeight) |
Protected Member Functions | |
CSimpleCube (TUint aWidth, TUint aHeight) | |
void | ConstructL (void) |
Private Attributes | |
TUint | iScreenWidth |
TUint | iScreenHeight |
TRenderingMode | iDrawingMode |
|
Destructor. Does nothing. Definition at line 149 of file SimpleCube.cpp.
|
|
Standard constructor that must never Leave. Stores the given screen width and height.
Definition at line 136 of file SimpleCube.cpp. Referenced by NewL(). 00136 : 00137 iScreenWidth( aWidth ), 00138 iScreenHeight( aHeight ) 00139 { 00140 }
|
|
Factory method for creating a new CSimpleCube object. Definition at line 117 of file SimpleCube.cpp. References CSimpleCube(). Referenced by CSimpleCubeContainer::ConstructL(). 00118 { 00119 /* Symbian 2-phase constructor. Calls both the default 00120 C++ constructor and Symbian ConstructL methods */ 00121 CSimpleCube* self = new (ELeave) CSimpleCube( aWidth, aHeight ); 00122 CleanupStack::PushL( self ); 00123 self->ConstructL(); 00124 CleanupStack::Pop(); 00125 00126 return self; 00127 }
|
|
Initializes OpenGL ES, sets the vertex and color arrays and pointers. Also selects the shading mode. Definition at line 172 of file SimpleCube.cpp. References iDrawingMode, iScreenHeight, iScreenWidth, and SetScreenSize(). Referenced by CSimpleCubeContainer::ConstructL(). 00173 { 00174 // Initialize viewport and projection. 00175 SetScreenSize( iScreenWidth, iScreenHeight ); 00176 00177 // Set the screen background color. 00178 glClearColor( 0.f, 0.f, 0.f, 1.f ); 00179 00180 // Enable back face culling. 00181 glEnable( GL_CULL_FACE ); 00182 00183 // Enable vertex arrays. 00184 glEnableClientState( GL_VERTEX_ARRAY ); 00185 00186 // Set array pointers. 00187 glVertexPointer( 3, GL_BYTE, 0, vertices ); 00188 00189 // Enable color arrays. 00190 glEnableClientState( GL_COLOR_ARRAY ); 00191 00192 // Set color pointers. 00193 glColorPointer( 4, GL_UNSIGNED_BYTE, 0, colors ); 00194 00195 // Set the initial shading mode 00196 glShadeModel( GL_FLAT ); 00197 00198 // Do not use perspective correction 00199 glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST ); 00200 00201 // Set the initial drawing mode 00202 iDrawingMode = ETriangles; 00203 }
|
|
Called upon application exit. Does nothing. Definition at line 212 of file SimpleCube.cpp. Referenced by CSimpleCubeContainer::~CSimpleCubeContainer().
|
|
Draws a 3D box with triangles or triangle fans depending on the current rendering mode.Scales the box to the given size using glScalef.
Definition at line 224 of file SimpleCube.cpp. References iDrawingMode. Referenced by AppCycle(). 00225 { 00226 glScalef( aSizeX, aSizeY, aSizeZ ); 00227 00228 if ( iDrawingMode == ETriangles ) 00229 { 00230 glDrawElements( GL_TRIANGLES, 12 * 3, GL_UNSIGNED_BYTE, triangles ); 00231 } 00232 else if ( iDrawingMode == ETriangleFans ) 00233 { 00234 glDrawElements( GL_TRIANGLE_FAN, 6 * 3, GL_UNSIGNED_BYTE, fanOne ); 00235 glDrawElements( GL_TRIANGLE_FAN, 6 * 3, GL_UNSIGNED_BYTE, fanTwo ); 00236 } 00237 }
|
|
Renders one frame.
Definition at line 247 of file SimpleCube.cpp. References DrawBox(). Referenced by CSimpleCubeContainer::DrawCallBack(). 00248 { 00249 const GLint cameraDistance = 100; 00250 00251 glClear( GL_COLOR_BUFFER_BIT ); 00252 00253 /* Animate and draw box */ 00254 glLoadIdentity(); 00255 glTranslatex( 0 , 0 , -cameraDistance << 16 ); 00256 glRotatex( aFrame << 16, 1 << 16, 0 , 0 ); 00257 glRotatex( aFrame << 15, 0 , 1 << 16, 0 ); 00258 glRotatex( aFrame << 14, 0 , 0 , 1 << 16 ); 00259 DrawBox( 15.f, 15.f, 15.f ); 00260 }
|
|
Sets the shading mode to flat. Definition at line 274 of file SimpleCube.cpp. Referenced by CSimpleCubeAppUi::HandleCommandL().
|
|
Sets the shading to smooth (gradient). Definition at line 286 of file SimpleCube.cpp. Referenced by CSimpleCubeAppUi::HandleCommandL().
|
|
Sets the rendering to use triangles. Definition at line 298 of file SimpleCube.cpp. References iDrawingMode. Referenced by CSimpleCubeAppUi::HandleCommandL(). 00299 { 00300 iDrawingMode = ETriangles; 00301 }
|
|
Sets the rendering to use triangle fans. Definition at line 310 of file SimpleCube.cpp. References iDrawingMode. Referenced by CSimpleCubeAppUi::HandleCommandL(). 00311 { 00312 iDrawingMode = ETriangleFans; 00313 }
|
|
Notifies that the screen size has dynamically changed during execution of this program. Resets the viewport to this new size.
Definition at line 320 of file SimpleCube.cpp. References iScreenHeight, and iScreenWidth. Referenced by AppInit(), and CSimpleCubeContainer::SizeChanged(). 00321 { 00322 iScreenWidth = aWidth; 00323 iScreenHeight = aHeight; 00324 00325 // Reinitialize viewport and projection. 00326 glViewport( 0, 0, iScreenWidth, iScreenHeight ); 00327 00328 // Recalculate the view frustrum 00329 glMatrixMode( GL_PROJECTION ); 00330 glLoadIdentity(); 00331 GLfloat aspectRatio = (GLfloat)(iScreenWidth) / (GLfloat)(iScreenHeight); 00332 glFrustumf( FRUSTUM_LEFT * aspectRatio, FRUSTUM_RIGHT * aspectRatio, 00333 FRUSTUM_BOTTOM, FRUSTUM_TOP, 00334 FRUSTUM_NEAR, FRUSTUM_FAR ); 00335 glMatrixMode( GL_MODELVIEW ); 00336 }
|
|
Second phase contructor. Does nothing. Definition at line 160 of file SimpleCube.cpp.
|
|
Width of the screen Definition at line 125 of file SimpleCube.h. Referenced by AppInit(), and SetScreenSize(). |
|
Height of the screen Definition at line 128 of file SimpleCube.h. Referenced by AppInit(), and SetScreenSize(). |
|
The current rendering mode Definition at line 131 of file SimpleCube.h. Referenced by AppInit(), DrawBox(), TriangleFanMode(), and TriangleMode(). |
© Nokia 2006 |