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 ShapesExample 3-15 Identity shaders...const int size = 8;unsigned int textureData[size*size];unsigned int color = 0xFFFFFFFF;for(int y = 0; y < size; y++){for(int x = 0; x < size; x++ ){color ^= 0xFFFFFF;textureData[y*size+x] = color;}color ^= 0xFFFFFF;}// create an empty texture named checkerBoardManaged checkerBoard = context->createTexture2D();checkerBoard->setFilterMode(GL_NEAREST, GL_NEAREST);...// use the textureData array to fill the texturecheckerBoard->buildMipmaps(0, size, size, GL_RGBA, textureData);The MipMaps object is used, and the dimensions of the rendered shape and the texturesource are different.Note• The checkboard texture is a 2D shape.• The fragmentshader texture sets the pixel value based on the value of a point in the2D texture shape:gl_FragColor = texture2D(texture, texcoord);4. As with Example 3-9 on page 3-8 which combined the vertex and color data in one array,the code in Example 3-16 combines the vertices and texture locations:Example 3-16 Specifying the location for the shape and texture......GLfloat vertexData[24] ={// X Y U V-1.0f, -1.0f, 0.0f, 0.0f, // values for each vertex of the first triangle1.0f, -1.0f, 1.0f, 0.0f,-1.0f, 1.0f, 0.0f, 1.0f,1.0f, -1.0f, 1.0f, 0.0f, // values for each vertex of the second triangle1.0f, 1.0f, 1.0f, 1.0f,-1.0f, 1.0f, 0.0f, 1.0f};/* Set up the vertex buffer */Managed vertexBuffer = context->createBuffer(GL_ARRAY_BUFFER, sizeof(vertexData),sizeof(GLfloat)*4);vertexBuffer->setData(0, sizeof(vertexData), vertexData);ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 3-12ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!