Mali GPU User Interface Engine Application Development Guide
Mali GPU User Interface Engine Application Development Guide
Mali GPU User Interface Engine Application Development Guide
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Tutorial on Drawing 3D Shapes}{mat4 localTransform = node->data->sampleLocalTransform(time);parentTransform = localTransform * parentTransform;node->data->setAbsoluteTransform(parentTransform);}traverseTransform(node->getFirstChild(), parentTransform, time);void applyMaterial(MaterialAsset* m, Context* context){if (m){if (m->commonMaps.diffuse) context->setUniformSampler("diffuseMap", m->commonMaps.diffuse->getTexture());if (m->commonMaps.bump) context->setUniformSampler("normalMap", m->commonMaps.bump->getTexture());if (m->commonMaps.spec_level)context->setUniformSampler("glossMap", m->commonMaps.spec_level->getTexture());}}void 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);for (unsigned int i = 0; i < node->data->getBatchCount(); i++){Batch b = node->data->getBatch(i);applyMaterial(b.material, context);b.geometry->draw();}}traverseDraw(node->getFirstChild(), context);}...3. Example 4-60 shows the initialization and loading of the asset files:Example 4-60 Creating the context and loading the scene assets...int main(int argc, char** argv){t_args args;int width = 640;int height = 480;static int frameCount = 1;float current_time = 0.0;float old_time = 0.0;static int first_time = 1;if ( 0 != parse_arguments( argc, argv, &args )) exit(1);ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-48ID070710Non-Confidential - Draft - Beta