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
Contributor
markmanca
Posts: 14
Registered: ‎10-01-2010
My Device: Not Specified
Accepted Solution

glReadPixels crashing when used from a Cascades app?

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-Samples.  The OpenGL rendering occurs in a separate thread.

 

My code looks like this (yes, it isn't optimal, but it works for testing):

 

    unsigned char* pImage = (unsigned char*)::malloc(500 * 1000 * 3);
    ::glPixelStorei(GL_PACK_ALIGNMENT, 1);
    ::glReadPixels(0, 0, 500, 1000, GL_RGB, GL_UNSIGNED_BYTE, pImage);
    ::free(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.

 

Thanks,

Mark

 

Please use plain text.
BlackBerry Development Advisor
RSperanza
Posts: 141
Registered: ‎03-08-2012
My Device: Z10
My Carrier: Bell

Re: glReadPixels crashing when used from a Cascades app?

Hi.

 

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.

Please use plain text.
BlackBerry Development Advisor
RSperanza
Posts: 141
Registered: ‎03-08-2012
My Device: Z10
My Carrier: Bell

Re: glReadPixels crashing when used from a Cascades app?

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.

Please use plain text.
Contributor
markmanca
Posts: 14
Registered: ‎10-01-2010
My Device: Not Specified

Re: glReadPixels crashing when used from a Cascades app?

I can verify that beta 4 fixes the problem!  The exact same code that was causing the crash in beta 3 does not crash in beta 4.  Thanks!

Please use plain text.