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.1 Drawing a simple 3D cubeThis tutorial describes a constructing a simple cube:1. Locate the shader example project 01 Hello World and open the hello_world.cpp file.2. Example 4-1 shows the initialization code and the function to calculate the cameraposition:Example 4-1 Camera position for hello world#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), 2.0f, radius * sin(angleRad));}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(".");...Proxy proxy(filesystem, context);3. Unlike with the simple 2D examples, the shaders code is in an external file. The functiongetProgram() loads the shaders and manges their eventual destruction. See Example 4-2.Example 4-2 Loading the hello_world shaders......Program *helloWorldProgram =proxy.getProgram("shaders/hello_world.vert;shaders/hello_world.frag");4. Set the vertex position as shown in Example 4-3 on page 4-3.ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-2ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!