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 the System ClassesDrawing and swapping buffers continues until either:• the context is told to close by the operating system. If this happens,context->update() returns false.• the keyboard interface processes an Esc keypress.4. The mouse detection code is shown in Example 2-9:Example 2-9 Reacting to mouse events}if(mouse->isButtonDown(Mouse::LEFT_BUTTON)){// Get X and Y coordinatesxClick = mouse->getAxisPosition(Mouse::X_AXIS);yClick = mouse->getAxisPosition(Mouse::Y_AXIS);printf("Mouse click at: %i, %i \n", xClick, yClick);}Note• The getAxisPosition() functions are called whenever the mouse button is down, somultiple printf() statements are called for each button depression.• If the mouse click is outside the draw window, an event is still generated.• You can use the Observer class to simplify using the mouse in an application.5. Example 2-10 shows the exception-handler code for the application:Example 2-10 Catching an exception from the draw loop...}catch(Exception& e){printf("An exception was thrown:\n%s\n", e.getMessage().getCharString() );}}6. Compile and run the project.Because the context is used in this example, the graphics output window shown inFigure 2-2 is displayed:Figure 2-2 Blank graphics contextARM DUI 0527A-02a Copyright © 2010 ARM. All rights reserved. 2-7ID070710Non-Confidential - Draft - Beta

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

Saved successfully!

Ooh no, something went wrong!