|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
#include <SimpleCubePbuffer.h>
Public Member Functions | |
| virtual | ~CSimpleCubePbuffer () |
| 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 | SetScreenSize (TUint aWidth, TUint aHeight) |
Static Public Member Functions | |
| static CSimpleCubePbuffer * | NewL (TUint aWidth, TUint aHeight) |
Protected Member Functions | |
| CSimpleCubePbuffer (TUint aWidth, TUint aHeight) | |
| void | ConstructL (void) |
Private Attributes | |
| TUint | iScreenWidth |
| TUint | iScreenHeight |
Definition at line 36 of file SimpleCubePbuffer.h.
|
|
Destructor. Does nothing. Definition at line 127 of file SimpleCubePbuffer.cpp.
|
|
||||||||||||
|
Standard constructor that must never Leave. Stores the given screen width and height.
Definition at line 120 of file SimpleCubePbuffer.cpp. 00120 : 00121 iScreenWidth( aWidth ), 00122 iScreenHeight( aHeight ) 00123 { 00124 }
|
|
||||||||||||
|
Factory method for creating a new CSimpleCubePbuffer object. Definition at line 100 of file SimpleCubePbuffer.cpp. References CSimpleCubePbuffer(). 00101 { 00102 /* Symbian 2-phase constructor. Calls both the default 00103 C++ constructor and Symbian ConstructL methods */ 00104 CSimpleCubePbuffer* self = new (ELeave) CSimpleCubePbuffer( aWidth, aHeight ); 00105 CleanupStack::PushL( self ); 00106 self->ConstructL(); 00107 CleanupStack::Pop(); 00108 00109 return self; 00110 }
|
|
|
Initializes OpenGL ES, sets the vertex and color arrays and pointers. Also selects the shading mode. Definition at line 151 of file SimpleCubePbuffer.cpp. References iScreenHeight, and iScreenWidth. 00152 { 00153 // Set the screen background color. 00154 glClearColor( 0.f, 0.f, 0.f, 1.f ); 00155 00156 // Enable back face culling. 00157 glEnable( GL_CULL_FACE ); 00158 00159 // Initialize viewport and projection. 00160 glViewport( 0, 0, iScreenWidth, iScreenHeight ); 00161 glMatrixMode( GL_PROJECTION ); 00162 00163 // Calculate the view frustrum 00164 GLfloat aspectRatio = (GLfloat)(iScreenWidth) / (GLfloat)(iScreenHeight); 00165 glFrustumf( FRUSTUM_LEFT * aspectRatio, FRUSTUM_RIGHT * aspectRatio, 00166 FRUSTUM_BOTTOM, FRUSTUM_TOP, 00167 FRUSTUM_NEAR, FRUSTUM_FAR ); 00168 00169 glMatrixMode( GL_MODELVIEW ); 00170 00171 // Enable vertex arrays. 00172 glEnableClientState( GL_VERTEX_ARRAY ); 00173 00174 // Set array pointers. 00175 glVertexPointer( 3, GL_BYTE, 0, vertices ); 00176 00177 // Enable color arrays. 00178 glEnableClientState( GL_COLOR_ARRAY ); 00179 00180 // Set color pointers. 00181 glColorPointer( 4, GL_UNSIGNED_BYTE, 0, colors ); 00182 00183 // Set the initial shading mode 00184 glShadeModel( GL_FLAT ); 00185 00186 // Do not use perspective correction 00187 glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST ); 00188 00189 00190 }
|
|
|
Called upon application exit. Does nothing. Definition at line 199 of file SimpleCubePbuffer.cpp.
|
|
||||||||||||||||
|
Draws a 3D box.Scales the box to the given size using glScalef.
Definition at line 212 of file SimpleCubePbuffer.cpp. 00213 { 00214 glScalef( aSizeX, aSizeY, aSizeZ ); 00215 00216 glDrawElements( GL_TRIANGLES, 12 * 3, GL_UNSIGNED_BYTE, triangles ); 00217 }
|
|
|
Renders one frame.
Definition at line 228 of file SimpleCubePbuffer.cpp. References DrawBox(). 00229 { 00230 00231 glClear( GL_COLOR_BUFFER_BIT ); 00232 00233 // Animate and draw box 00234 glLoadIdentity(); 00235 glTranslatex( 0 , 0 , -cameraDistance << 16 ); 00236 glRotatex( aFrame << 16, 1 << 16, 0 , 0 ); 00237 glRotatex( aFrame << 15, 0 , 1 << 16, 0 ); 00238 glRotatex( aFrame << 14, 0 , 0 , 1 << 16 ); 00239 DrawBox( 15.f, 15.f, 15.f ); 00240 }
|
|
|
Sets the shading mode to flat. Definition at line 255 of file SimpleCubePbuffer.cpp.
|
|
|
Sets the shading to smooth (gradient). Definition at line 268 of file SimpleCubePbuffer.cpp.
|
|
||||||||||||
|
Notifies that the screen size has dynamically changed during execution of this program. Resets the viewport to this new size.
Definition at line 279 of file SimpleCubePbuffer.cpp. References iScreenHeight, and iScreenWidth. 00280 { 00281 iScreenWidth = aWidth; 00282 iScreenHeight = aHeight; 00283 00284 // Reinitialize OpenGL ES 00285 // Set the screen background color. 00286 glClearColor( 0.f, 0.f, 0.f, 1.f ); 00287 00288 // Enable back face culling. 00289 glEnable( GL_CULL_FACE ); 00290 00291 // Initialize viewport and projection. 00292 glViewport( 0, 0, iScreenWidth, iScreenHeight ); 00293 glMatrixMode( GL_PROJECTION ); 00294 glFrustumf( -1.f, 1.f, -1.f, 1.f, 3.f, 1000.f ); 00295 glMatrixMode( GL_MODELVIEW ); 00296 00297 // Enable vertex arrays. 00298 glEnableClientState( GL_VERTEX_ARRAY ); 00299 00300 // Set array pointers. 00301 glVertexPointer( 3, GL_BYTE, 0, vertices ); 00302 00303 // Enable color arrays. 00304 glEnableClientState( GL_COLOR_ARRAY ); 00305 00306 // Set color pointers. 00307 glColorPointer( 4, GL_UNSIGNED_BYTE, 0, colors ); 00308 00309 // Set the initial shading mode 00310 glShadeModel( GL_FLAT ); 00311 00312 // Do not use perspective correction 00313 glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST ); 00314 00315 // Recalculate the view frustrum 00316 glMatrixMode( GL_PROJECTION ); 00317 glLoadIdentity(); 00318 GLfloat aspectRatio = (GLfloat)(iScreenWidth) / (GLfloat)(iScreenHeight); 00319 glFrustumf( FRUSTUM_LEFT * aspectRatio, FRUSTUM_RIGHT * aspectRatio, 00320 FRUSTUM_BOTTOM, FRUSTUM_TOP, 00321 FRUSTUM_NEAR, FRUSTUM_FAR ); 00322 glMatrixMode( GL_MODELVIEW ); 00323 }
|
|
|
Second phase contructor. Does nothing. Definition at line 139 of file SimpleCubePbuffer.cpp.
|
|
© Nokia 2006 |