13.07.2015 Views

Mali GPU User Interface Engine Application Development Guide

Mali GPU User Interface Engine Application Development Guide

Mali GPU User Interface Engine Application Development Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Tutorial on the Lotion <strong>User</strong> <strong>Interface</strong> Classes5.4.2 Modified startup code in lightshow.cppThe original lighshow.cpp file in ...\example_applications\lightshow is not the same as the onein ...\lotion\applets\lightshow:• the standalone application is converted to a be a class• additional code is added to interface with the theme and application classes.The modified lightshow.cpp file uses the header file and the Lotion namespaces as shown in :Example 5-20 Namespace for lightshow// add reference to new header file#include "lightshow.h"// remove low-level includesusing namespace MDE;namespace Lotion // use Lotion namespace{namespace Applets // use Applets namespace{...}}The first part of lightshow.cpp file is similar to the original, except that some widget code hasbeen added as shown in Example 5-21:Example 5-21 Functions in lightshow.cpp// same as original except now class methodvoid LightShow::prepareFlares(Context* context, MDE::Program* p){float texcoords[] = { 0, 0, 1, 0, 1, 1, 0, 1 };flareTexcoord = context->createBuffer(GL_ARRAY_BUFFER,sizeof(texcoords), 8);flareTexcoord->setData(0, sizeof(texcoords), texcoords);flareTexcoordsLoc = p->getAttribLocation(TEXCOORD0);}// same as original except now class methodvoid LightShow::drawFlare(Context* context, vec3 position, vec3 color, float size){context->setUniform("position", position);context->setUniform("color", color);context->setUniform("size", size);glEnableVertexAttribArray(flareTexcoordsLoc);glBindBuffer(GL_ARRAY_BUFFER, flareTexcoord->getHandle());glVertexAttribPointer(flareTexcoordsLoc, 2, GL_FLOAT, GL_FALSE, 0, 0);unsigned short indices[] = { 0, 1, 2, 0, 2, 3 };glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);}glDisableVertexAttribArray(flareTexcoordsLoc);ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 5-26ID070710Non-Confidential - Draft - Beta

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!