Mali GPU User Interface Engine Application Development Guide
Mali GPU User Interface Engine Application Development Guide
Mali GPU User Interface Engine Application Development Guide
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}applyMaterial(b.material, context);if (useWireframe) {for (unsigned int j = 0; j < b.geometry->getVertexBufferCount(); j++){if (b.geometry->getVertexBuffer(j))context->setVertexBuffer(j, b.geometry->getVertexBuffer(j));}if (b.geometry->getVertexDeclaration())context->setVertexDeclaration(b.geometry-> getVertexDeclaration());if (b.geometry->getIndexBuffer())context->drawElements(GL_LINE_STRIP, 0,b.geometry->getPrimitiveCount() * 3,b.geometry->getIndexBuffer());}else{b.geometry->draw();}}}traverseDraw(node->getFirstChild(), context);5.4.4 Utility functions for lightingLightShow(), angles_for_lights(), and calculate_cyl_info() are identical to the original exceptfor the namespace.See Example 5-23:Example 5-23 Utility functions for lighting// same as original except now class methodfloat LightShow::fract(float v) {return v - floor(v);}// same as original except now class methodvec2 LightShow::angles_for_light(vec2 cyl_pos, float cyl_radius, vec2 light_position) {vec2 light_cyl = cyl_pos - light_position;float light_dist = light_cyl.length();float scale_factor = (0.5f / 3.141532f);float cyl_center_angle = atan2(light_cyl.y, light_cyl.x) * scale_factor;float cyl_radius_angle = sin(cyl_radius / light_dist) * scale_factor;return vec2(cyl_center_angle - cyl_radius_angle,cyl_center_angle + cyl_radius_angle);}vec3 LightShow::calculate_cyl_info(vec2 cyl_pos, float cyl_radius,vec2 light_position, float light_radius) {vec2 light_cyl = cyl_pos - light_position;vec2 light_sideway_vec = vec2(light_cyl.y, -light_cyl.x).normalized();float light_dist = light_cyl.length();}vec2 angles = angles_for_light(cyl_pos, cyl_radius, light_position);float offset = fract((angles.x + angles.y) / 2.0);float limit = 0.5 - fract(angles.y - offset);vec3 shadow_info(offset, light_dist, limit);return shadow_info;ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 5-28ID070710Non-Confidential - Draft - Beta