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 Shapes...{}if (keyboard->getSpecialKeyState(Keyboard::KEY_RIGHT)){world_object *= mat4::rotation(1.0f, vec3(0.0f, 0.0f, 1.0f));}if (keyboard->getSpecialKeyState(Keyboard::KEY_LEFT)){world_object *= mat4::rotation(-1.0f, vec3(0.0f, 0.0f, 1.0f));}8. Example 4-50 shows the part of the draw loop that sets the uniform values and draws theteapot:Example 4-50 Drawing the teapot in the cube mapping environment...tmp = proj * view;wvpMatrix_object = tmp * world_object;wvpMatrix_skybox = tmp * world_skybox;// Initialize the object's program/uniforms and draw it.context->setProgram(cube_reflection);context->setUniformMatrix("WORLD_VIEW_PROJECTION", wvpMatrix_object);context->setUniformMatrix("WORLD", world_object.toMat3());context->setUniform("CAMERA_POSITION", camPos);context->setUniformSampler("environmentCubeMap", textureCube);...teapot->draw();9. Example 4-51 shows the part of the draw loop that sets the uniform values and draws theenvironment:Example 4-51 Drawing the cube environment...// Initialize skybox's program/uniforms and draw it.context->setProgram(skybox);context->setUniformMatrix("WORLD_VIEW_PROJECTION", wvpMatrix_skybox);context->setUniformSampler("skyboxCubeMap", textureCube);}context->setVertexDeclaration(vertexDeclaration);context->setVertexBuffer(0, vertexBuffer);context->drawElements(GL_TRIANGLES, 0, 12, indexBuffer);}while ( context->update() );}catch (Exception &e){printf(e.getMessage().getCharString());}10. Rebuild the project and run it. Figure 4-21 on page 4-40 shows two views of the shape inthe environment:ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-39ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!