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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Tutorial on the Lotion <strong>User</strong> <strong>Interface</strong> Classes// same as original except now class methodvoid LightShow::traverseTransform(Tree* node,mat4 parentTransform, float time){if (!node)return;traverseTransform(node->getNextSibling(), parentTransform, time);if (node->data) {mat4 localTransform = node->data->sampleLocalTransform(time);parentTransform = localTransform * parentTransform;node->data->setAbsoluteTransform(parentTransform);}traverseTransform(node->getFirstChild(), parentTransform, time);}// same as original except now class methodvoid LightShow::applyMaterial(MaterialAsset* m, Context* context){if (m) {if (m->commonMaps.diffuse)context->setUniformSampler("diffuseMap",m->commonMaps.diffuse->getTexture());if (m->commonMaps.bump) {Texture* t = m->commonMaps.bump->getTexture();context->setUniformSampler("normalMap", t);}}}if (m->commonMaps.spec_level)context->setUniformSampler("glossMap",m->commonMaps.spec_level->getTexture());5.4.3 Changes to traverseDraw()The traverseDraw() function is the same except for the namespace and the addition of a loopthrough the batches. See Example 5-22:Example 5-22 traverseDraw() function// now class method and display options configurable by radio buttonsvoid LightShow::traverseDraw(Tree* node, Context* context) {if (!node)return;traverseDraw(node->getNextSibling(), context);if (node->data){mat4 world = node->data->getAbsoluteTransform();context->setUniformMatrix("WORLD", world);mat4 inv_trans_world = world.transposed();inv_trans_world.invert(inv_trans_world);context->setUniformMatrix("INV_TRANS_WORLD", inv_trans_world);// new for applet, loop through batchesfor (unsigned int i = 0; i < node->data->getBatchCount(); i++){Batch b = node->data->getBatch(i);ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 5-27ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!