Mali GPU User Interface Engine Application Development Guide
Mali GPU User Interface Engine Application Development Guide
Mali GPU User Interface Engine Application Development Guide
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 Shapesvec3 camPos = calculateCamPos(4.0f, cameraAngle);vec3 camTarget = vec3(0.0f, 0.0f, 0.0f);vec3 upVector = vec3(0.0f, 1.0f, 0.0f);// Set up the view and projection matrices and multiply them to get the// modelviewprojection matrix.mat4 proj = mat4::perspective(35.0f, 1.0f, 0.1f, 100.0f);mat4 view = mat4::lookAt(camPos, camTarget, upVector);mat4 world = mat4::identity();mat4 wvpMatrix = proj * view * world;// Set the program to use and initialize the uniformscontext->setProgram(texturingProgram);context->setUniformSampler("texture", static_cast(texture));glEnable(GL_DEPTH_TEST);...6. Example 4-12 shows the draw loop which reacts to keyboard input to change the cameraand view:Example 4-12 Reacting to keyboard input to change the view...do{// 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(4.0f, ++cameraAngle);view = mat4::lookAt(camPos, camTarget, upVector);}if (keyboard->getSpecialKeyState(Keyboard::KEY_RIGHT)){camPos = calculateCamPos(4.0f, --cameraAngle);view = mat4::lookAt(camPos, camTarget, upVector);}}else{if (keyboard->getSpecialKeyState(Keyboard::KEY_RIGHT)){world *= mat4::rotation(1.0f, vec3(0.0f, 1.0f, 0.0f));}if (keyboard->getSpecialKeyState(Keyboard::KEY_LEFT)){world *= mat4::rotation(-1.0f, vec3(0.0f, 1.0f, 0.0f));}}wvpMatrix = proj * view * world;ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-10ID070710Non-Confidential - Draft - Beta