Mali GPU User Interface Engine Application Development Guide
Mali GPU User Interface Engine Application Development Guide
Mali GPU User Interface Engine Application Development Guide
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 Shapes5. The second element in the elements array is defined, and the semantic attribute is TECOORD0.See Example 3-3 on page 3-3:Example 3-17 Setting VertexElement to use a texture...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[1].components = 2;elements[1].offset = 2*sizeof(GLfloat);elements[1].semantic = TEXCOORD0;elements[1].stream = 0;elements[1].type = GL_FLOAT;// xy position// this element is the vertices for the shapes// uv position// this element is texture information...Managed vertexDeclaration = context->createVertexDeclaration(elements, 2);context->setVertexDeclaration(vertexDeclaration);6. The shape and texture have been defined, so draw the shape as shown in Example 3-18.Example 3-18 Draw a shape with a custom texture...do{glClearColor(1.0f, 0.0f, 0.0f, 1.0f);glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );context->setVertexBuffer(0, vertexBuffer);/** When dealing with 2D textures and shaders, we need to assign the texture to a sampler.*/context->setUniformSampler("texture", (Texture*)checkerBoard);context->drawArrays( GL_TRIANGLES, 0, 2 );if(keyboard->getSpecialKeyState(Keyboard::KEY_ESCAPE)) break;}while( context->update() );}}catch(Exception& e){printf("MDE Exception: \n%s\n\n",e.getMessage().getCharString());}7. Figure 3-5 on page 3-14 shows the shape with its texture:ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 3-13ID070710Non-Confidential - Draft - Beta