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 ShapesExample 4-48 Set the camera, projection, view, and world for cube mapping...// The camera position, target and up vector for use when creating the view matrixfloat cameraAngle = 0.0f;vec3 camPos = calculateCamPos(75.0f, cameraAngle);vec3 camTarget = vec3(0.0f, 0.0f, 0.0f);vec3 upVector = vec3(0.0f, 1.0f, 0.0f);// Set up the view, projection and world matrices. We don't precalculate the// modelviewprojection-matrices because it will have to be changed for each frame// as we change the view matrix to rotate the camera.mat4 view = mat4::lookAt(camPos, camTarget, upVector);mat4 proj = mat4::perspective(60.0f, 4.0f/3.0f, 1.0f, 300.0f);// Set up the world matrix for the object.mat4 world_object = mat4::rotation(90.0, vec3(-1.0f, 0.0f, 0.0f)) *mat4::rotation(90.0, vec3(0.0f, 0.0f, 1.0f));mat4 wvpMatrix_object;// Set up the world matrix for the skybox.mat4 world_skybox = mat4::scale(200.0f, 200.0f, 200.0f);mat4 wvpMatrix_skybox;mat4 tmp;...glEnable(GL_DEPTH_TEST);7. Example 4-49 shows the part of the draw loop that reacts to keyboard input to change thecamera, view, and lighting:Example 4-49 Use the to keyboard input to change the cube mapping view...do{glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );// Exit the applicationif (keyboard->getSpecialKeyState(Keyboard::KEY_ESCAPE)){return 0;}// Rotate object or cameraif (keyboard->getSpecialKeyState(Keyboard::KEY_SPACE)){if (keyboard->getSpecialKeyState(Keyboard::KEY_LEFT)){camPos = calculateCamPos(75.0f, --cameraAngle);view = mat4::lookAt(camPos, camTarget, upVector);}if (keyboard->getSpecialKeyState(Keyboard::KEY_RIGHT)){camPos = calculateCamPos(75.0f, ++cameraAngle);view = mat4::lookAt(camPos, camTarget, upVector);}}elseARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-38ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!