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 Shapes...}// calculate new camera positioncamPos = calculateCamPos(75.0f, --cameraAngle);// create a view based on the new camera positionview = 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)){// create a world matrix to rotate the teapotworld *= 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));}7. Example 4-26 shows the part of the draw loop that sets the uniform values and draws theteapot:Example 4-26 Drawing the teapot with lighting...wvpMatrix = proj * view * world;// Have to set the uniforms each frame since the above call to setProgram// clears them.context->setUniformMatrix("WORLD_VIEW_PROJECTION", wvpMatrix);context->setUniformMatrix("WORLD", world.toMat3());context->setUniform("LIGHT_POSITION", lightPosition);context->setUniform("CAMERA_POSITION", camPos);context->setUniform("AMBIENT_LIGHT", AMBIENT_LIGHT);context->setUniform("DIFFUSE_LIGHT", DIFFUSE_LIGHT);context->setUniform("SPECULAR_LIGHT", SPECULAR_LIGHT);context->setUniform("COLOR", ::COLOR);// 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){printf(e.getMessage().getCharString());}8. Rebuild the project and run it. Figure 4-5 on page 4-21 shows the shape:ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-20ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!