11-13-2012 02:38 AM
I am attempting to use glReadPixels() from an OpenGL ES 2.0 enabled Cascades app. Unfortunately, it crashes.
If I use glReadPixels() from within the OpenGL ES 2.0 Native SDK Template that the QDE creates (non-Cascades/native only), it works.
But, if I use it from a OpenGL ES 2.0 enabled Cascades app, it fails.
I am using it from within a ForeignWindowControl. I am using a modified version of the GoodCitizenCascades sample (which I modified to work with BlackBerry 10 Beta 3 -- the original only works with Beta 2) found here: https://github.com/blackberry/Cascades-Community-S
My code looks like this (yes, it isn't optimal, but it works for testing):
unsigned char* pImage = (unsigned char*)::malloc(500 * 1000 * 3);
::glReadPixels(0, 0, 500, 1000, GL_RGB, GL_UNSIGNED_BYTE, pImage);
The debugger shows the app crashing within one of the subroutines that glReadPixels() is calling. Unfortunately, there isn't much detail to go on besides that.
I don't think it is the width/height as they are below what the screen width/height is set to.
The code is called immediately after the other objects are drawn to the screen, and before the swap buffers call is made. So it is called from the same thread and at the same time as the other OpenGL drawing operations.
I've compared how the sample initializes OpenGL for Cascades vs how the Native OpenGL ES2.0 template initializes OpenGL, and they are basically the same.
If there is a place to upload projects/complete sets of code, I'd be happy to do that.
Solved! Go to Solution.
11-16-2012 05:37 PM
I am the author of GoodCitizenCascades. The update sample app is still in progress which is why it is not posted at this time. The updated sample should be ready in time for the next beta release.
I will try the code snippet with the latest code this weekend and let you know what I find out.
11-28-2012 05:46 PM
I pasted the code (but removed the ::'s) into the latest GoodCitizen.cpp class and the app did not crash. I'm running this with a recent release so it may have been due to a bug in the older app code or possibly a bug in the OS you are using now. I'm submitting the latest version for review later this week and it should be posted sometime next week. You should also upgrade to the latest beta of BlackBerry 10 when it is released.