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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Tutorial on Drawing 2D Shapes3.1 Drawing a triangleThis section describes how to draw a 2D triangle:1. Select the tutorial project 06 - Drawing a Triangle the Hard Way and open the main.cppfile.2. Example 3-1 shows placing the processing code, including the initialization code for thecontext and keyboard, in to a try block:Example 3-1 Creating the system objects#include using namespace MDE;int main(int argc, char** argv){try{Managed system = create_system_backend();Managed context = system->createContext(320, 240);Managed timer = system->createTimer();#ifdef MDE_OS_PC_LINUXManaged keyboard = system->createKeyboard(context);#elseManaged keyboard = system->createKeyboard();#endif...Use the Context interface to:• create a context to draw with• create GL objects that are linked to a context such as:— textures— buffers— shader programs.3. Because this example actually draws a shape to the context, there must be a vertex andfragment shader. Example 3-2 shows how to define simple identity shaders:Example 3-2 Identity shaders.../** Define the shader sources. The following GLSL shaders define a simple identity-transform vertex* shader and a fragment shader which outputs the color value calculated in the vertex shader.*/const char* vertexsource ="attribute vec4 POSITION; \attribute vec4 COLOR;\varying vec4 col;\void main(void)\{\col = COLOR;\gl_Position = POSITION;\}";ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 3-2ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!