os/graphics/graphicstest/uibench/s60/src/model.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicstest/uibench/s60/src/model.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,74 @@
     1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +#ifndef MODEL_H_
    1.21 +#define MODEL_H_
    1.22 +
    1.23 +
    1.24 +#include "geometrystructs.h"
    1.25 +#include <e32base.h>
    1.26 +
    1.27 +#include <GLES/egl.h>
    1.28 +
    1.29 +
    1.30 +class CSolidSphere;
    1.31 +
    1.32 +/*
    1.33 + The model class contains one or more shapes and some knowledge of how to
    1.34 + arrange and light them to create a scene. It knows how to do two things:
    1.35 + - change the resolution of the shapes in the scene, which involves 
    1.36 + recalculating their vertices.
    1.37 + - draw the scene to a buffer by drawing, arranging and lighting the shapes
    1.38 + using Open GL ES commands.
    1.39 + 
    1.40 + It understands that these two operations may be happening in different 
    1.41 + threads, so it serialises access to the model data (the vertices) with a mutex.  
    1.42 + */
    1.43 +
    1.44 +class CModel : public CBase
    1.45 +    {
    1.46 +public:
    1.47 +    static CModel* NewL(EGLDisplay aDisplay, EGLSurface aSurface, TPtrC aBackgroundColor);
    1.48 +    static CModel* NewL(EGLDisplay aDisplay, EGLSurface aSurface);
    1.49 +    ~CModel();
    1.50 +    void PrecalculateOrbitL(TInt aOrbitingDistance, RArray<Vertex3F>& aVertices, TInt aPositionCount, TReal aAngle);
    1.51 +    void SetResolutionL(TInt aResolution);
    1.52 +    void DrawToBuffer(TInt aTime) const;
    1.53 +    
    1.54 +    enum {ERed = 0, EGreen, EBlue, EAlpha};
    1.55 +    
    1.56 +private:
    1.57 +    CModel(EGLDisplay aDisplay, EGLSurface aSurface);
    1.58 +    void ConstructL(TPtrC aBackgroundColor);
    1.59 +    void SetShapes(CSolidSphere* aSun, CSolidSphere* aPlanet, CSolidSphere* aSatellite);
    1.60 +    void InitialiseFrame() const;
    1.61 +    void DrawModelData(TInt aTime) const;
    1.62 +    
    1.63 +private:
    1.64 +    EGLDisplay iDisplay;
    1.65 +    EGLSurface iSurface;
    1.66 +
    1.67 +    CSolidSphere* iSun;
    1.68 +    CSolidSphere* iPlanet;
    1.69 +    CSolidSphere* iMoon;
    1.70 +    
    1.71 +    RArray<Vertex3F> iSunPositions;
    1.72 +    RArray<Vertex3F> iMoonPositions;
    1.73 +    GLclampf iBackgroundColor[4];
    1.74 +    TInt iResolution;
    1.75 +    };
    1.76 +
    1.77 +#endif /* MODEL_H_ */