os/graphics/graphicstest/uibench/s60/src/model.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 
    17 #ifndef MODEL_H_
    18 #define MODEL_H_
    19 
    20 
    21 #include "geometrystructs.h"
    22 #include <e32base.h>
    23 
    24 #include <GLES/egl.h>
    25 
    26 
    27 class CSolidSphere;
    28 
    29 /*
    30  The model class contains one or more shapes and some knowledge of how to
    31  arrange and light them to create a scene. It knows how to do two things:
    32  - change the resolution of the shapes in the scene, which involves 
    33  recalculating their vertices.
    34  - draw the scene to a buffer by drawing, arranging and lighting the shapes
    35  using Open GL ES commands.
    36  
    37  It understands that these two operations may be happening in different 
    38  threads, so it serialises access to the model data (the vertices) with a mutex.  
    39  */
    40 
    41 class CModel : public CBase
    42     {
    43 public:
    44     static CModel* NewL(EGLDisplay aDisplay, EGLSurface aSurface, TPtrC aBackgroundColor);
    45     static CModel* NewL(EGLDisplay aDisplay, EGLSurface aSurface);
    46     ~CModel();
    47     void PrecalculateOrbitL(TInt aOrbitingDistance, RArray<Vertex3F>& aVertices, TInt aPositionCount, TReal aAngle);
    48     void SetResolutionL(TInt aResolution);
    49     void DrawToBuffer(TInt aTime) const;
    50     
    51     enum {ERed = 0, EGreen, EBlue, EAlpha};
    52     
    53 private:
    54     CModel(EGLDisplay aDisplay, EGLSurface aSurface);
    55     void ConstructL(TPtrC aBackgroundColor);
    56     void SetShapes(CSolidSphere* aSun, CSolidSphere* aPlanet, CSolidSphere* aSatellite);
    57     void InitialiseFrame() const;
    58     void DrawModelData(TInt aTime) const;
    59     
    60 private:
    61     EGLDisplay iDisplay;
    62     EGLSurface iSurface;
    63 
    64     CSolidSphere* iSun;
    65     CSolidSphere* iPlanet;
    66     CSolidSphere* iMoon;
    67     
    68     RArray<Vertex3F> iSunPositions;
    69     RArray<Vertex3F> iMoonPositions;
    70     GLclampf iBackgroundColor[4];
    71     TInt iResolution;
    72     };
    73 
    74 #endif /* MODEL_H_ */