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.

inside custom component

Native Development

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

Camera callbacks and openGL

Hello,

 

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,

Please use plain text.
New Developer
Immortal_Flame
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.

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

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.

 

Cheers,

Sean

 

Please use plain text.