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#endifManaged filesystem = system->createFileSystem(".");Managed timer = system->createTimer();Proxy proxy(filesystem, context);// Load programsProgram* cube_reflection =proxy.getProgram("shaders/cube_reflection_mapping.vert;shaders/cube_reflection_mapping.frag");Program* skybox = proxy.getProgram("shaders/skybox.vert;shaders/skybox.frag");// Load sceneSceneAsset* scene = proxy.getSceneAsset("data/teapot.mba");GeometryAsset* teapot =static_cast(scene->getAsset(Asset::TYPE_GEOMETRY, 0));// Load cubemapManaged textureCube = loadCubeMap(context, proxy);textureCube->setWrapMode(GL_CLAMP_TO_EDGE);textureCube->setFilterMode(GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);...3. There are four shaders:skybox.vertThe vertex shader in Example 4-42 calculates the vertex coordinate to use inthe fragment shader:Example 4-42 skybox.vert shader for cube mappinguniform mat4 WORLD_VIEW_PROJECTION;attribute vec4 POSITION;attribute vec3 NORMAL;varying vec3 vTexCoord;void main(void){gl_Position = WORLD_VIEW_PROJECTION * POSITION;vTexCoord = POSITION.xyz;}skybox.fragThe fragment shader in Example 4-43 maps the environment bitmap to theskybox cube.Example 4-43 skybox.frag shader for cube mappinguniform samplerCube skyboxCubeMap;varying vec3 vTexCoord;void main(void){gl_FragColor = textureCube(skyboxCubeMap, vTexCoord);}ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-35ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!