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

Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.

New Developer
Posts: 3
Registered: ‎06-27-2012
My Device: Playbook
My Carrier: -
Accepted Solution

Camera callbacks and openGL



I am trying to combine the camera API with openGL ( so I can generate overlays and such on the camera images in native ), and am encountering some issues, hopefully someone here can help me with resolving them.


I am using the new NDK 2.1.0 beta for the playbook, and am initializing opengl and egl through the generic bbutil functions supplied in the examples. After this, I initialize the camera library, set up an appropriate photo viewfinder, and issue the command to take a picture. This all works fine without any troubles.


I then use the image_callback of camera_take_photo() to do some extra analysis on the picture taken, extract the image data from it, all still working fine, up untill the point where I am trying to generate a texture from the data.


I have a global GLuint variable named tex --- just as in the examples, for simplicity --- and I am calling glGenTextures(1,&tex) in the callback function, resulting in a segfault for me. It does not matter whether I am using a GLuint * tex, with the appropriate variable adaptations, and it does not work when I pass the GLuint as the final parameter of the callback function.


Does anybody already has some experience on the callback functions of the camera API, or does anybody know wheter opengl is still fully initialized when the callback functions execute? The debugger function shows a lot of threads, but I am not skilled enough in BB programming yet to know that this is what is going wrong.


Any type of help would be appreciated,

New Developer
Posts: 3
Registered: ‎06-27-2012
My Device: Playbook
My Carrier: -

Re: Camera callbacks and openGL

Okay, so apparently, after a lot more of trial-and-error based exploration, it turns out that openGL is indeed not initialized during the execution of the callback functions.


Just thought I should let people here know, to maybe save them the headaches.

BlackBerry Development Advisor
Posts: 683
Registered: ‎11-29-2011
My Device: PRIV
My Carrier: Rogers

Re: Camera callbacks and openGL

The callback functions are just pthreads, so if OpenGL is not cross-thread capable, then this would be a problem.

There is an event-based API rolling out shortly which would allow you to catch the callback events in your main event loop instead of using the threaded callbacks.  It is not yet integrated with bps, but it should at least simplify the task of doing the processing on your main thread.