egl/sfegltest/src/vgline.cpp
author Gareth Stockwell <gareth.stockwell@accenture.com>
Fri, 05 Nov 2010 17:31:20 +0000
branchbug235_bringup_0
changeset 215 097e92a68d68
parent 211 3804ba25b23f
permissions -rw-r--r--
Added GLES 1.x spinning cube-rendering code to eglbringuptest The coordinate, color and index data are uploaded to server-side buffers by the CGLES1Cube::KhrSetup function. CGLES1Cube::KhrPaint just sets the view matrix and issues a draw command. Which demo to display can be selected by passing its name on the command line, e.g. eglbringuptest vgline eglbringuptest gles1cube If no name is provided, the application defaults to vgline.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     1
// Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     2
// All rights reserved.
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     3
// This component and the accompanying materials are made available
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     5
// which accompanies this distribution, and is available
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     7
//
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     8
// Initial Contributors:
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    10
//
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    11
// Contributors:
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    12
//
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    13
// Description:
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    14
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    15
#include "vgline.h"
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    16
215
097e92a68d68 Added GLES 1.x spinning cube-rendering code to eglbringuptest
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 211
diff changeset
    17
_LIT(KVGLineName, "vgline");
097e92a68d68 Added GLES 1.x spinning cube-rendering code to eglbringuptest
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 211
diff changeset
    18
097e92a68d68 Added GLES 1.x spinning cube-rendering code to eglbringuptest
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 211
diff changeset
    19
CEGLRendering* CVGLine::NewL(RWindow& aWindow)
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    20
    {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    21
    CVGLine* self = new (ELeave) CVGLine(aWindow);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    22
    CleanupStack::PushL(self);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    23
    self->ConstructL();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    24
    CleanupStack::Pop(self);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    25
    return self;
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    26
    }
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    27
215
097e92a68d68 Added GLES 1.x spinning cube-rendering code to eglbringuptest
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 211
diff changeset
    28
const TDesC& CVGLine::Name()
097e92a68d68 Added GLES 1.x spinning cube-rendering code to eglbringuptest
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 211
diff changeset
    29
	{
097e92a68d68 Added GLES 1.x spinning cube-rendering code to eglbringuptest
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 211
diff changeset
    30
	return KVGLineName;
097e92a68d68 Added GLES 1.x spinning cube-rendering code to eglbringuptest
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 211
diff changeset
    31
	}
097e92a68d68 Added GLES 1.x spinning cube-rendering code to eglbringuptest
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 211
diff changeset
    32
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    33
CVGLine::CVGLine(RWindow& aWindow)
215
097e92a68d68 Added GLES 1.x spinning cube-rendering code to eglbringuptest
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 211
diff changeset
    34
    :   CEGLRendering(aWindow, EGL_OPENVG_API)
097e92a68d68 Added GLES 1.x spinning cube-rendering code to eglbringuptest
Gareth Stockwell <gareth.stockwell@accenture.com>
parents: 211
diff changeset
    35
	{
211
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    36
    }
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    37
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    38
void CVGLine::KhrSetup()
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    39
    {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    40
    static VGubyte const Segments[] =
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    41
        {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    42
        VG_MOVE_TO_ABS,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    43
        VG_LINE_TO_REL,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    44
        VG_CLOSE_PATH
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    45
        };
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    46
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    47
    static VGfloat const Coords[] =
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    48
        {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    49
        110, 35,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    50
        50, 160,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    51
        };
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    52
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    53
    VGfloat strokeColor[4]  = {1.f, 0.f, 0.f, 1.f};
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    54
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    55
    RDebug::Printf("[EBT] CVGLine::KhrSetup vgCreatePaint");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    56
    iVGPaint = vgCreatePaint();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    57
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    58
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    59
    RDebug::Printf("[EBT] CVGLine::KhrSetup vgSetParameterX");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    60
    vgSetParameteri(iVGPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    61
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    62
    vgSetParameterfv(iVGPaint, VG_PAINT_COLOR, 4, strokeColor);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    63
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    64
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    65
    RDebug::Printf("[EBT] CVGLine::KhrSetup vgCreatePath");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    66
    iVGPath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    67
                            VG_PATH_DATATYPE_F,
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    68
                            1.0f, // scale
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    69
                            0.0f, // bias
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    70
                            3,    // segmentCapacityHint
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    71
                            4,    // coordCapacityHint
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    72
                            VG_PATH_CAPABILITY_ALL);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    73
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    74
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    75
    RDebug::Printf("[EBT] CVGLine::KhrSetup vgAppendPathData");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    76
    vgAppendPathData(iVGPath, sizeof(Segments), Segments, Coords);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    77
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    78
    }
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    79
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    80
void CVGLine::KhrPaint()
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    81
    {
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    82
    RDebug::Printf("[EBT] CVGLine::KhrPaint vgSetPaint");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    83
    vgSetPaint(iVGPaint, VG_STROKE_PATH);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    84
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    85
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    86
    RDebug::Printf("[EBT] CVGLine::KhrPaint vgDrawPath");
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    87
    vgDrawPath(iVGPath, VG_STROKE_PATH);
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    88
    VGCheckError();
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    89
    }
3804ba25b23f Refactored eglbringuptest to separate EGL and VG code
Gareth Stockwell <gareth.stockwell@accenture.com>
parents:
diff changeset
    90