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 the System Classes2.3 Creating an OpenGL ES rendering contextThis example draws to the context:1. Open the main.cpp file from the 02 - Creating an OpenGL Rendering Context project.Example 2-6 shows the creation of the System, Context, and Keyboard interfaces:Example 2-6 Create a rendering context#include using namespace MDE;int main(){try // all of the code is in a try block{Managed system = create_system_backend();Managed context = system->createContext(320, 240);...#ifdef MDE_OS_PC_LINUXMDE::Managed keyboard = system->createKeyboard(context);#elseMDE::Managed keyboard = system->createKeyboard();#endif2. Example 2-7 shows how to create a mouse object with the MDE library:Example 2-7 Creating a mouseint xClick, yClick;// create a mouse objectManaged mouse= system->createMouse(context);3. Example 2-8 shows the draw loop:Example 2-8 Draw loop for empty context......while(true){glClearColor(1.0f, 0.0f, 0.0f, 1.0f);glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);/** The update() function will swap buffers to refresh the image on the screen.* The function returns false if the context is told to close by the operating* system.*/if(!context->update()) break;if(keyboard->getSpecialKeyState(Keyboard::KEY_ESCAPE)) break;The clear color is specified as (1.0f, 0.0f, 0.0f, 1.0f) which is red.Each call to update() swaps the draw buffers and returns true if the context is still active.ARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 2-6ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!