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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Tutorial on Drawing 3D Shapes4.5 Bump mapping on the cubeThis tutorial combines:• using a geometry asset, in this example it is a cube• bump mapping• reacting to keyboard input to rotate the cube or move the camera.1. Locate the shader example 05 - BumpMapping and open the bumpmapping.cpp file.2. Example 4-33 shows the standard initialization code:Example 4-33 Initialization for the Bump Mapping application...##include using namespace MDE;const float AMBIENT = 0.2;const float DIFFUSE_CONTRIBUTION = 0.7;const float SPECULAR_CONTRIBUTION = 0.4;static const vec3 AMBIENT_LIGHT = vec3 (0.2f, 0.2f, 0.2f);static const vec3 DIFFUSE_LIGHT = vec3(0.7f, 0.7f, 0.7f);static const vec3 SPECULAR_LIGHT = vec3(0.4f, 0.4f, 0.4f);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), radius * sin(angleRad), 0.0f);}int main(int argc, char * argv[]){try{// Initialize the demo engine classesManaged system = create_system_backend();Managed context = system->createContext(320, 240);#ifdef MDE_OS_PC_LINUXManaged keyboard = system->createKeyboard(context);#elseManaged keyboard = system->createKeyboard();#endifManaged filesystem = system->createFileSystem("./data");Managed timer = system->createTimer();Proxy proxy(filesystem, context);// Loading programsProgram* perVertexLightingProgram =proxy.getProgram("../shaders/bumpmapping.vert;../shaders/bumpmapping.frag");...3. Previous examples specified the locations for each vertex. Example 4-34 on page 4-26shows how to load an asset file that contains the information:ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-25ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!