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


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.


Reply
Contributor
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

 

BlackBerry Development Advisor
Posts: 143
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.

BlackBerry Development Advisor
Posts: 143
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.

Highlighted
Contributor
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!