Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Native Development

Reply
Developer
nathanpc
Posts: 127
Registered: ‎05-19-2012
My Carrier: VIVO Brazil
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;

	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?

If I helped you please click the "Like" button to support my work.
My apps: GAGmobile - CherryNotes - Requests
Social Me: about.me - Twitter
Please use plain text.
Developer
BGmot
Posts: 966
Registered: ‎11-24-2011
My Carrier: x

Re: Handling Touch Events

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

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

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

    screen_stop_events((screen_context_t) esContext->screen_context);

    terminateGraphics(esContext);

    bps_shutdown();

    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)...

 

Please use plain text.