Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Posts: 134
Registered: ‎05-19-2012
My Device: Torch 9800, PlayBook 64GB, Dev Alpha
Accepted Solution

Handling Touch Events

I'm reading the OpenGL ES 2.0 Programming Guide and on their examples the use a helper library that they've created called esUtil.h (which has a version for BlackBerry), that is contained on the book examples repository, the problem is that now I want to handle touch events, but I don't know how to make my code compactible with the bbutil.h initialization so I can take advantage of the touch and at the same time have esUtil.h so I can take advantage of functions like esRegisterDrawFuncesRegisterUpdateFunc and esMainLoop, which I don't know how to do with bbutil. Here's my code:


#include <stdlib.h>
#include <stdio.h>
#include "esUtil/esUtil.h"

// BlackBerry stuff.
#include "bbutil.h"
#include <bps/bps.h>
#include <bps/screen.h>

// Helpers.
#include "helpers/global.h"
#include "helpers/shaders.h"

// Scene.
#include "scene/scene.h"

int main(int argc, char *argv[]) {
	ESContext esContext;
	UserData userData;

	esContext.userData = &userData;

	if (!esCreateWindow(&esContext, TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, ES_WINDOW_RGB))
		return 0;

	if (!init(&esContext))
		return 0;

	esRegisterDrawFunc(&esContext, drawScene);
	esRegisterUpdateFunc(&esContext, update);


	return 0;

 Any suggestions?

If I helped you please click the "Like" button to support my work.
My apps: CherryNotes - Bookmarked - Requests
Social Me: about.me - Twitter
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook

Re: Handling Touch Events

esMainLoop() just calls QNX implementation MainLoop defined in esUtil_qnx.c

void MainLoop(ESContext *esContext)
    for (;;)
        if (__qnx.shouldExit)

        // Call update function if registered
        if (esContext->updateFunc != NULL)
            esContext->updateFunc(esContext, getElapsedTime() / 1000.0f);
        if (esContext && esContext->drawFunc)

    screen_stop_events((screen_context_t) esContext->screen_context);



    screen_destroy_context((screen_context_t) esContext->screen_context);

 So, apparently you should be looking at modifying handle_events() and deep down handleScreenEvent() (also defined in esUtil_qnx.c.

Good luck. OpenGL is very interesting (and powerful)...