Handling Touch Events With the BlackBerry Native SDK

343 Views Asked by At

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 esRegisterDrawFunc, esRegisterUpdateFunc 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;

    esInitContext(&esContext);
    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);

    esMainLoop(&esContext);

    return 0;
}

Any suggestions?

1

There are 1 best solutions below

0
On

I don't have any specific experience mixing OpenGL with BPS, but since there hasn't been any other response...

I have mixed BPS with Cascades under BB10. What I did was run the BPS event fetching and response code on a separate thread. The thread will block until BPS has an event. This leaves the main thread available for Cascades (in my case) or esMainLoop (in your case).