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 ShapesFigure 3-3 The 2D triangle with per-vertex coloring and floating-point color values3.2.3 Combining the position coordinates and color values into a single array1. Locate the tutorial project 06 - Drawing a Triangle the Hard Way and open the main.cppfile.2. Modify the triangle data from Example 3-9 on page 3-8 to move the values fromcolorData[] to the corresponding row in vertexData[]. Delete the code that assigns valuesto colorData[].Example 3-11 Vertex shading of simple triangle with floating-point color values......GLfloat vertexData[] ={-1.0, -1.0, 1.0, 0, 0, 1.0,1.0, -1.0, 0, 1.0, 0, 1.0,0.0, 1.0 0, 0, 1.0, 1.0};3. Modify the vertex information from Example 3-5 on page 3-4 to create vertexBufferbased on the larger vertexData array as shown in Example 3-12:Example 3-12 Using floating-point values for the color buffers...Managed vertexBuffer = context->createBuffer(GL_ARRAY_BUFFER, sizeof(vertexData),sizeof(GLfloat)*6);vertexBuffer->setData(0, sizeof(vertexData), vertexData);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 = 2*sizeof(GLfloat);elements[1].semantic = COLOR;elements[1].stream = 1;ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 3-9ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!