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 ShapesExample 4-38 Use the to keyboard input to change the view, camera, and lighting......do{// Exit the application if the escape key is pressedif (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);}}else{if (keyboard->getSpecialKeyState(Keyboard::KEY_RIGHT)){world *= mat4::rotation(1.0f, vec3(0.0f, 0.0f, 1.0f));}if (keyboard->getSpecialKeyState(Keyboard::KEY_LEFT)){world *= mat4::rotation(-1.0f, vec3(0.0f, 0.0f, 1.0f));}}9. Example 4-39 shows the part of the draw loop that sets the uniform values and draws theteapot:Example 4-39 Drawing the bump-mapped object...wvpMatrix = proj * view * world;context->setUniformMatrix("WORLD_VIEW_PROJECTION", wvpMatrix);context->setUniformMatrix("WORLD", world.toMat3());// Clear the screen and draw teapot with lightingglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );teapot->draw();}while ( context->update() );}catch (Exception &e){ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-29ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!