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 Drawing 3D Shapes4.8 Lightshow animation with moving sprite and cameraThis tutorial combines:• a complex geometry asset• multiple varying light sources• frame rate calculation• automated movement of the camera• automated movement of a simple shape.Open the Lightshow example application:1. Example 4-58 shows the code in main.cpp that draws the flare:Example 4-58 Drawing the flare...void prepareFlares(Context* context, 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);void 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);2. Example 4-59 shows the code that traverses the tree that contains the paths:Example 4-59 Path traversal functionsvoid traverseTransform(Tree* node, mat4 parentTransform, float time){if (!node) return;traverseTransform(node->getNextSibling(), parentTransform, time);if (node->data)ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-47ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!