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};0.5f, 0.5f, -0.5f, // 2-0.5f, 0.5f, -0.5f, // 3-0.5f, -0.5f, 0.5f, // 40.5f, -0.5f, 0.5f, // 50.5f, 0.5f, 0.5f, // 6-0.5f, 0.5f, 0.5f // 7GLushort indexData[] ={0, 1, 2, //front0, 2, 3,1, 5, 6, //right1, 6, 2,5, 4, 7, //back5, 7, 6,4, 0, 3, //left4, 3, 7,3, 2, 6, //top3, 6, 7,4, 5, 1, //bottom4, 1, 0};// Set up vertex buffer and index bufferBuffer* vertexBuffer =context->createBuffer(GL_ARRAY_BUFFER, sizeof(vertexData), sizeof(GLfloat)*3);vertexBuffer->setData(0, sizeof(vertexData), vertexData);5. Example 4-47 shows how to create an element buffer that contains the index lists:Example 4-47 Creating the element bufferBuffer* indexBuffer =context->createBuffer(GL_ELEMENT_ARRAY_BUFFER, sizeof(indexData), sizeof(unsigned short));indexBuffer->setData(0, sizeof(indexData), indexData);// Set up vertex declaration for the vertex data stream.VertexElement elements[1];elements[0].components = 3;elements[0].offset = 0;elements[0].semantic = POSITION;elements[0].stream = 0;elements[0].type = GL_FLOAT;...Managed vertexDeclaration =context->createVertexDeclaration(elements, 1);To standardize creation of vertex buffers and index buffers, use Context::createBuffer().When creating a buffer, specify the target as either:• GL_ARRAY_BUFFER for vertex buffers that will contain vertex attributes• GL_ELEMENT_ARRAY_BUFFER for index buffers that will contain index lists forglDrawElements.6. Example 4-48 on page 4-38 shows the camera, projection, view, and world setup:ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 4-37ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!