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 Shapes...const char* fragmentsource ="precision mediump float; \varying vec4 col;\void main(void)\{\gl_FragColor = col;\}";4. The shaders in vertexsource and fragmentsource are text strings that contain the source.Example 3-3 shows how to associate the shaders with the context:a. compile the shaders with createShader()b. use createProgram() to create a new program that uses the compiled shadersc. activate the program for the context with setProgram().Example 3-3 Building the identity shaders....../** Create Shader and Program objects. This is done using the createShader() and createProgram() functions* on the context object. We then set our newly created program active using setProgram().*/Managed vertexshader = context->createShader(GL_VERTEX_SHADER, vertexsource);Managed fragmentshader = context->createShader(GL_FRAGMENT_SHADER, fragmentsource);Managed program = context->createProgram(vertexshader, fragmentshader);context->setProgram(program);The vertexshader, fragmentshader, and program all use the Managed template format toautomatically manage object destruction.5. Specify the triangle as shown in Example 3-4. There are two parts to the specification:• Because this is a 2D triangle, there are three coordinates and each coordinate isspecified with two numbers that locate the vertex in the XY plane.• This example uses vertex coloring, but all of the colors for the triangle vertices areset to red. Colors are specified with four numbers that indicate the red, blue, green,and alpha channel values.Example 3-4 Triangle coordinates......GLfloat vertexData[] ={-1.0, -1.0,1.0, -1.0,0.0, 1.0};GLubyte colorData[] ={255, 0, 0, 255,255, 0, 0, 255,255, 0, 0, 255};ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 3-3ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!