graphicsdeviceinterface/directgdi/test/tdirectgdieglcontent_cube.h
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2007-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  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21 
       
    22 #ifndef __TDIRECTGDIEGLCONTENT_CUBE_H__
       
    23 #define __TDIRECTGDIEGLCONTENT_CUBE_H__
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <pixelformats.h>
       
    27 #include <graphics/sgimage.h>
       
    28 #include <graphics/sgimagecollection.h>
       
    29 #include <GLES/egl.h>
       
    30 
       
    31 const TInt KEglContentBuffers = 2;
       
    32 
       
    33 /**
       
    34 This class contains cube GL renderer.
       
    35 CGLCube initializes the EGL environment and renders off-screen pixmap surfaces. 
       
    36 Creation of the pixmap is based on RSgImage resource which is initialized 
       
    37 with parameter  TsgImageInfo.iUsage set to EsgUsageOpenGlesTarget|ESgUsageDirectGdiSource.  
       
    38 OpenGL ES API is used to reneder content of the pixmap. The result is available as a TSgDrawableId object.
       
    39 */
       
    40 class CGLCube : public CBase
       
    41 	{
       
    42 public:
       
    43 	static CGLCube* NewL(TUidPixelFormat aPixelFormat, const TSize& aSize);
       
    44 	static CGLCube* NewLC(TUidPixelFormat aPixelFormat, const TSize& aSize);
       
    45 	virtual ~CGLCube();
       
    46 
       
    47 	void Render(TInt aFrame);
       
    48 	void GetImage(TSgDrawableId& aId);
       
    49 
       
    50 private:
       
    51 	CGLCube();
       
    52 	void ConstructL(TUidPixelFormat aPixelFormat, const TSize& aSize);
       
    53 	void InitEglL(TUidPixelFormat aPixelFormat, const TSize& aSize);
       
    54 	void DeInitEgl();
       
    55 
       
    56 private:
       
    57 	/** Display where the OpenGL ES window surface resides. */
       
    58 	EGLDisplay iEglDisplay;
       
    59 
       
    60 	/** Describes the format, type and size of the color buffers and ancillary buffers for EGLSurface. */
       
    61 	EGLConfig iConfig;
       
    62 
       
    63 	/** The image where the framebuffer is drawn. */
       
    64 	TSgImageInfo iImageInfo;
       
    65 	RSgImage iImages[KEglContentBuffers];
       
    66 
       
    67 	/** Current image buffer number */
       
    68 	TInt iCurrentImage;
       
    69 	TInt iLastImage;
       
    70 
       
    71 	/** Pixmap surface (that uses the iPixmap) that is the target of OpenGL ES graphics rendering. */
       
    72 	EGLSurface iEglSurfaces[KEglContentBuffers];
       
    73 
       
    74 	/** OpenGL ES rendering context. */
       
    75 	EGLContext iEglContext;
       
    76 
       
    77 	/** OpenGL ES Texture id */
       
    78 	GLuint iTexId;
       
    79 	};
       
    80 
       
    81 #endif