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 Drawing 3D Shapes4.4 Controlling lighting effectsThis tutorial combines:• using a geometry asset, in this example it is a teapot• selecting between per-vertex and per-pixel lighting• reacting to keyboard input to rotate the cube or move the camera.1. Locate the shader example 04 - Lighting and open the lighting.cpp file.2. Example 4-17 shows the standard initialization code. This example also has vectors forthe light sources:Example 4-17 Initialization for the teapot lighting application...#include using namespace MDE;static const float TIMEOUT = 0.3f;static const vec3 AMBIENT_LIGHT = vec3 (0.1f, 0.1f, 0.1f);static const vec3 DIFFUSE_LIGHT = vec3(0.5f, 0.5f, 0.5f);static const vec3 SPECULAR_LIGHT = vec3(0.5f, 0.5f, 0.5f);static const vec4 COLOR = vec4(1.0f, 0.0f, 0.0f, 1.0f);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);3. Example 4-18 on page 4-16 shows the code that loads the lighting programs:ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-15ID070710Non-Confidential - Draft - Beta