08-11-2012 11:33 AM
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?
Solved! Go to Solution.
08-13-2012 09:50 AM
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)...