egl/sfegltest/src/eglrendering.cpp
author Gareth Stockwell <gareth.stockwell@accenture.com>
Fri, 22 Oct 2010 22:42:40 +0100
branchbug235_bringup_0
changeset 211 3804ba25b23f
parent 210 da03feddbab7
child 215 097e92a68d68
permissions -rw-r--r--
Refactored eglbringuptest to separate EGL and VG code This allows for a more complex demo (e.g. one which includes animated rendering) to be implemented simply by writing a new class derived from CEglRendering, and modifying CWsApp::ConstructL to create an instance of this new class.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     2
// All rights reserved.
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     7
//
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     8
// Initial Contributors:
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    10
//
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    11
// Contributors:
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    12
//
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    13
// Description:
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    14
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    15
#include "eglrendering.h"
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    16
#include <string.h>
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    17
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    18
const TInt KTimerDelay = 0;
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    19
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    20
/** Attributes to be passed into eglChooseConfig */
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    21
const EGLint KAttribList[] =
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    22
		{
205
c7cc034fd51d Set AttribsList back to RGBA8888
bdonegan
parents: 204
diff changeset
    23
		EGL_RED_SIZE,			8,
c7cc034fd51d Set AttribsList back to RGBA8888
bdonegan
parents: 204
diff changeset
    24
		EGL_GREEN_SIZE,			8,
c7cc034fd51d Set AttribsList back to RGBA8888
bdonegan
parents: 204
diff changeset
    25
		EGL_BLUE_SIZE,			8,
c7cc034fd51d Set AttribsList back to RGBA8888
bdonegan
parents: 204
diff changeset
    26
        EGL_ALPHA_SIZE,         8,
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    27
		EGL_SURFACE_TYPE,		EGL_WINDOW_BIT,
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    28
		EGL_RENDERABLE_TYPE,	EGL_OPENVG_BIT,
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    29
		EGL_NONE
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    30
		};
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    31
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    32
void CEGLRendering::EGLCheckError()
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    33
    {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    34
    EGLint error = eglGetError();
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    35
    if(EGL_SUCCESS != error)
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    36
        {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    37
        RDebug::Printf("[EBT] CEglRendering::EGLCheckError error %d", error);
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    38
        User::Panic(_L("EBT-EGL"), error);
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    39
        }
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    40
    }
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    41
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    42
void CEGLRendering::EGLCheckReturnError(EGLBoolean aBool)
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    43
    {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    44
    if(!aBool)
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    45
        {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    46
        RDebug::Printf("[EBT] CEglRendering::EGLCheckReturnError false");
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    47
        User::Panic(_L("EGL-EGL-RTN"), eglGetError());
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    48
        }
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    49
    }
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    50
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    51
void CEGLRendering::VGCheckError()
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    52
    {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    53
    VGint error = vgGetError();
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    54
    if(VG_NO_ERROR != error)
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    55
        {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    56
        RDebug::Printf("[EBT] CEglRendering::VGCheckError error %d", error);
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    57
        User::Panic(_L("EBT-VG"), error);
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    58
        }
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    59
    }
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    60
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    61
CEGLRendering::CEGLRendering(RWindow& aWindow)
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    62
	:  iWindow(aWindow)
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    63
	{
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    64
	}
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    65
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    66
/*
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    67
 * Construct EGL objects, and OpenVG binding.
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    68
 *
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    69
 * Here we collaborate with EGL to associate a session, pick and configuration, assign
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    70
 * it to the window we have, and then bind the OpenVG rendering API to our newly created
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    71
 * context.
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    72
 *
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    73
 * In bring up terms, here is where the first EGL code entry points are called from.  Its
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    74
 * the natural point where an EGL bringup starts debugging from, assuming the core EGL
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    75
 * works in terms of supporting EGL sync objects (needed for boot before we get to the
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    76
 * ESHELL command prompt).
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    77
 */
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    78
void CEGLRendering::ConstructL()
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    79
    {
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    80
	RDebug::Printf("[EBT] CEGLRendering::ConstructL");
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
    81
	iRedrawTimer = CPeriodic::NewL(CActive::EPriorityIdle);
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    82
	EglSetupL();
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
    83
	KhrSetup();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
    84
	KhrPaint();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
    85
	EglSwapBuffers();
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    86
	}
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    87
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    88
void CEGLRendering::EglSetupL()
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    89
    {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    90
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL eglGetDisplay");
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    91
    iDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    92
    EGLCheckError();
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
    93
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    94
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL eglInitialize");
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    95
    EGLCheckReturnError(eglInitialize(iDisplay, NULL, NULL));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    96
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    97
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL vendor %s", eglQueryString(iDisplay, EGL_VENDOR));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    98
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL version %s", eglQueryString(iDisplay, EGL_VERSION));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
    99
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL extensions %s", eglQueryString(iDisplay, EGL_EXTENSIONS));
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   100
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   101
    // Check that EGL provides the capabilities for this app.
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   102
    if(NULL == strstr(eglQueryString(iDisplay, EGL_CLIENT_APIS), "OpenVG"))
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   103
        {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   104
        RDebug::Printf("[EBT] CEGLRendering::EglSetupL OpenVG not listed in supported client APIs %s", eglQueryString(iDisplay, EGL_CLIENT_APIS));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   105
        User::Leave(KErrNotSupported);
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   106
        }
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   107
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   108
    if(NULL == strstr(eglQueryString(iDisplay, EGL_EXTENSIONS), "EGL_SYMBIAN_COMPOSITION") )
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   109
        {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   110
        RDebug::Printf("[EBT] CEGLRendering::EglSetupL EGL_SYMBIAN_COMPOSITION not listed in extension string %s", eglQueryString(iDisplay, EGL_EXTENSIONS));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   111
        User::Leave(KErrNotSupported);
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   112
        }
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   113
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   114
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL eglChooseConfig");
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   115
    EGLint numConfigs = 0;
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   116
    EGLConfig chosenConfig = 0;
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   117
    EGLCheckReturnError(eglChooseConfig(iDisplay, KAttribList, &chosenConfig, 1, &numConfigs));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   118
    if (0 == numConfigs)
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   119
        {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   120
        RDebug::Printf("[EBT] No matching configs found", eglQueryString(iDisplay, EGL_EXTENSIONS));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   121
        User::Leave(KErrNotSupported);
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   122
        }
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   123
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   124
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL eglBindApi");
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   125
    EGLCheckReturnError(eglBindAPI(EGL_OPENVG_API));
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   126
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   127
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL eglCreateWindowSurface");
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   128
    iSurface = eglCreateWindowSurface(iDisplay, chosenConfig, &iWindow, NULL);
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   129
    EGLCheckError();
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   130
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   131
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL eglGetConfigAttrib");
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   132
    TInt redSize, greenSize, blueSize, alphaSize;
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   133
    EGLCheckReturnError(eglGetConfigAttrib(iDisplay, chosenConfig, EGL_ALPHA_SIZE, &alphaSize));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   134
    EGLCheckReturnError(eglGetConfigAttrib(iDisplay, chosenConfig, EGL_RED_SIZE, &redSize));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   135
    EGLCheckReturnError(eglGetConfigAttrib(iDisplay, chosenConfig, EGL_GREEN_SIZE, &greenSize));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   136
    EGLCheckReturnError(eglGetConfigAttrib(iDisplay, chosenConfig, EGL_BLUE_SIZE, &blueSize));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   137
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL id:%d alpha:%d red:%d green:%d blue:%d",
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   138
                   chosenConfig, alphaSize, redSize, greenSize, blueSize);
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   139
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   140
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL eglCreateContext");
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   141
    iContext = eglCreateContext(iDisplay, chosenConfig, EGL_NO_CONTEXT, NULL);
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   142
    EGLCheckError();
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   143
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   144
    RDebug::Printf("[EBT] CEGLRendering::EglSetupL eglMakeCurrent");
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   145
    CEGLRendering::EGLCheckReturnError(eglMakeCurrent(iDisplay, iSurface, iSurface, iContext));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   146
    }
203
71a455a885b7 Code to draw a line
bdonegan
parents: 202
diff changeset
   147
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   148
void CEGLRendering::EglSwapBuffers()
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   149
    {
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   150
    RDebug::Printf("[EBT] CEGLRendering::EglSwapBuffers");
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   151
    eglSwapBuffers(iDisplay, iSurface);
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   152
    EGLCheckError();
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   153
    }
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   154
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   155
CEGLRendering::~CEGLRendering()
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   156
    {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   157
    RDebug::Printf("[EBT] CEGLRendering::~CEGLRendering");
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   158
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   159
    StopRedrawTimer();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   160
    delete iRedrawTimer;
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   161
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   162
    if (EGL_NO_CONTEXT != iContext)
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   163
        {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   164
        EGLCheckReturnError(eglDestroyContext(iDisplay, iContext));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   165
        }
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   166
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   167
    if (EGL_NO_SURFACE != iSurface)
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   168
        {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   169
        EGLCheckReturnError(eglDestroySurface(iDisplay,iSurface));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   170
        }
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   171
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   172
    // Call eglMakeCurrent() to ensure the surfaces and contexts are truly destroyed.
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   173
    EGLCheckReturnError(eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   174
    EGLCheckReturnError(eglTerminate(iDisplay));
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   175
    EGLCheckReturnError(eglReleaseThread());
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   176
    }
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   177
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   178
void CEGLRendering::StartRedrawTimer()
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   179
    {
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   180
    // Start drawing the screen periodically
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   181
    iRedrawTimer->Start(0, KTimerDelay, TCallBack(TimerCallBack, this));
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   182
    }
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   183
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   184
void CEGLRendering::StopRedrawTimer()
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   185
    {
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   186
    if(iRedrawTimer)
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   187
        {
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   188
        iRedrawTimer->Cancel();
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   189
        }
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   190
    }
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   191
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   192
TInt CEGLRendering::TimerCallBack(TAny* aDemo)
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   193
	{
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   194
	static_cast<CEGLRendering*>(aDemo)->Redraw();
193
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   195
	return KErrNone;
bbf967b65d9e Add a bringup test program. Rom build is: buildrom syborg minigui_simulator eglbringuptest.iby The command to run is called ebt. See mmp file for documentation.
Faisal Memon <faisal.memon@nokia.com>
parents:
diff changeset
   196
	}
210
da03feddbab7 Cleaned up eglbringuptest code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 205
diff changeset
   197
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   198
void CEGLRendering::Redraw()
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   199
    {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   200
    RDebug::Printf("[EBT] CEGLRendering::Redraw");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   201
    KhrPaint();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   202
    EglSwapBuffers();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   203
    }
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 210
diff changeset
   204