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 Drawing 3D Shapes// specify flare.vert and flare.frag as the active shaderscontext->setProgram(flarePrg);context->setUniformMatrix("VIEW", view);context->setUniformMatrix("PROJECTION", proj);context->setUniformSampler("colorTex", flareTex);// call drawFlare with the light position, color, and flare sizedrawFlare(context, light0position, light0color, 10);glDepthMask(GL_TRUE);glDisable(GL_BLEND);frameCount++;}while (context->update());}catch(Exception& e){printf("An exception was thrown:\n%s\n", e.getMessage().getCharString() );}9. Example 4-66 shows the vertex shader code for the flare:Example 4-66 Flare vertex shader flare.vert...uniform mat4 VIEW;uniform mat4 PROJECTION;uniform float size;uniform vec3 position;attribute vec2 TEXCOORD0;varying vec2 outTexcoord;void main(void){// calculate the location of the flare in the world viewvec4 p = VIEW * vec4(position, 1.0);// increase the size of the flare// shift by -size to +size depending on value of TEXCOORD0p.xy += (TEXCOORD0 * 2.0 - 1.0) * size;// calculate the display positiongl_Position = PROJECTION * p;// forward the text coordinate to the fragment shaderoutTexcoord = TEXCOORD0;}10. Example 4-67 shows the fragment shader code for the flare:Example 4-67 Flare fragment shader flare.frag...uniform sampler2D colorTex;uniform vec3 color;void main(void){ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-54ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!