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 Shapes4.6 Cube mappingThis tutorial combines:• using a geometry asset, in this example it is a teapot• using mirror texturing• creating a skybox that gives the illusion of a complex background.Open the 8-Cube Mapping shader example:1. Example 4-40 shows the standard initialization code. The textureCube provides theenvironment that contains the shape:Example 4-40 Initialization for the cube mapping application...#include using namespace MDE;static const float PI = 3.14159265;/*** Function that calculates the camera position given an angle and a radius. This function* enables the camera to rotate around the scene object.*/inline vec3 calculateCamPos(float radius, float angle){float angleRad = angle / 180 * PI;return vec3(radius * cos(angleRad), 0.0f, radius * sin(angleRad));}/*** Function that loads 6 textures from the hard drive and creates a cubemap from them.*/Managed loadCubeMap(Managed context, Proxy &proxy){Managed textureCube = context->createTextureCube();MDE::Bitmap2DAsset* tmpTex = NULL;tmpTex = proxy.getBitmap2DAsset("data/3.png");textureCube->buildMipmaps(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0,tmpTex->getWidth(), tmpTex->getHeight(),tmpTex->getPixelFormat(), tmpTex->getPixels() );tmpTex = proxy.getBitmap2DAsset("data/opp.png");textureCube->buildMipmaps(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0,tmpTex->getWidth(), tmpTex->getHeight(),tmpTex->getPixelFormat(), tmpTex->getPixels() );tmpTex = proxy.getBitmap2DAsset("data/4.png");textureCube->buildMipmaps(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0,tmpTex->getWidth(), tmpTex->getHeight(),tmpTex->getPixelFormat(), tmpTex->getPixels() );tmpTex = proxy.getBitmap2DAsset("data/1.png");textureCube->buildMipmaps(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0,tmpTex->getWidth(), tmpTex->getHeight(),tmpTex->getPixelFormat(), tmpTex->getPixels() );tmpTex = proxy.getBitmap2DAsset("data/ned.png");textureCube->buildMipmaps(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0,ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-32ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!