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 2D Shapes6. The coordinate and color information are associated with new buffers as shown inExample 3-5:Example 3-5 Creating vertex and color buffers for the triangle...Managed vertexBuffer = context->createBuffer(GL_ARRAY_BUFFER, sizeof(vertexData),sizeof(GLfloat)*2);vertexBuffer->setData(0, sizeof(vertexData), vertexData);Managed colorBuffer = context->createBuffer(GL_ARRAY_BUFFER, sizeof(colorData),sizeof(GLubyte)*4);colorBuffer->setData(0, sizeof(colorData), colorData);VertexElement elements[2];elements[0].components = 2;elements[0].offset = 0;elements[0].semantic = POSITION;elements[0].stream = 0;elements[0].type = GL_FLOAT;elements[0].normalize = false;elements[1].components = 4;elements[1].offset = 0;elements[1].semantic = COLOR;elements[1].stream = 1;elements[1].type = GL_UNSIGNED_BYTE;elements[1].normalize = true;...Managed vertexDeclaration = context->createVertexDeclaration(elements, 2);context->setVertexDeclaration(vertexDeclaration);There are several buffers created in Example 3-5:a. createBuffer() creates vertexBuffer and colorBuffer objects from vertexData andcolorDatab. A VertexElement array named elements is created. The array size is two becausethere are position and color attributes for each vertex.c. Each VertexElement object describes one vertex attribute. The values of the each ofthe elements[] attributes is initialized:• The first element has two components because each vertex specifies aposition in the XY plane. The type is GL_FLOAT because floating-point numbersspecify the position.• The second element has four components because it specifies a color. Thetype is GL_UNSIGNED_BYTE because, in this example, 8-bit numbers specify thecolor and alpha channel values.For more information on attributes, see Passing data as uniforms on page 6-7.d. A vertexDeclaration object is created from elements. There are two objects in theelements array.e. setVertexDeclaration() associates the new vertexDeclaration object with thecontext.7. The triangle has been specified, so it can be drawn as shown in Example 3-6 on page 3-5.ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 3-4ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!