06-27-2012 06:44 PM
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,
Solved! Go to Solution.
06-28-2012 01:19 AM
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.
06-28-2012 11:33 AM
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.