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 2D ShapesFor each iteration of the loop:a. The first element of the vertex buffer that is associated with context is set to thevertexBuffer object defined previously.b. The second element of the vertex buffer that is associated with context is set to thecolorBuffer object defined previously.c. drawArrays() uses the vertex buffer arrays to draw the first object:• The object to draw is GL_TRIANGLES so three vertices are used.• The second parameter is 0, so the vertices start from the beginning of thebuffer.• The third parameter specifies the primitiveCount. There is only one primitive,a triangle, so the value is 1.d. A test for the escape key provides a way to end the display.e. If the context window is closed, update() returns false and the do loop ends.Example 3-6 Using the vertex information to draw the triangle...do{context->setVertexBuffer(0, vertexBuffer);context->setVertexBuffer(1, colorBuffer);/* Draw indexed triangles using the first 3 vertices of the buffers */context->drawArrays(GL_TRIANGLES, 0, 1);...if(keyboard->getSpecialKeyState(Keyboard::KEY_ESCAPE)) break;} while( context->update() );8. All of the execution code was enclosed in one try catch block which ends with the codein Example 3-7. If there is an exception, a message is displayed in the system window.Example 3-7 Trapping an exception in the triangle example...}}catch(Exception& e){printf("MDE \n%s\n\n", e.getMessage().getCharString());}9. Figure 3-1 on page 3-6 shows the triangle:ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 3-5ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!