iOS 6 GLES2 copyContentsToMemory returns all '\0'

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
josetomax
Gnoblar
Posts: 2
Joined: Mon Nov 05, 2012 7:41 am

iOS 6 GLES2 copyContentsToMemory returns all '\0'

Post by josetomax »

Hi everyone!

I´m using ogre 1.8.0 for iOS, and "copyContentsToMemory" method in my code to generate a screenshoot. It works perfectly in an iPhone 3GS with iOS 5, but is returning a buffer full of '/0's when running it on iPhone 4 with iOS 6.
Here is a fragment of the code:

Code: Select all

  unsigned char *data = new unsigned char [outWidth*outHeight*outBytesPerPixel];
	memset(data, 0, outWidth*outHeight*outBytesPerPixel);
	
	Ogre::Box extents(left, top, left + width, top + height);
	Ogre::PixelBox pb(extents, format, data);

        m_pOgreRenderWnd->copyContentsToMemory(pb, Ogre::RenderTarget::FB_FRONT);
I´ve also tried callling glReadPixels method, but the result is the same.

Any idea about what´s happening or alternative to this method to get it working in iOS 6 ?

Thanks in advance.
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: iOS 6 GLES2 copyContentsToMemory returns all '\0'

Post by masterfalcon »

I haven't tested that for a while. It's possible that it's broken or that maybe it's not working with retina resolutions. I'll have to check on it.
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: iOS 6 GLES2 copyContentsToMemory returns all '\0'

Post by masterfalcon »

BTW, what values are you using for outWidth, outHeight, outBytesPerPixel, left, top, and format?
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: iOS 6 GLES2 copyContentsToMemory returns all '\0'

Post by masterfalcon »

Nevermind, I figured it out.

There is a setting, new to iOS 6(I think) to specify whether you want the back buffer retained. Selecting no results better performance but does not guarantee that the contents will be there. And that means that glReadPixels may not work.

I don't want to just turn it on but I'm going to provide an option. Add "retainedBacking" as a bool in miscParams when creating your window and you should be good to go. I'm going to push this change to the 1.8 branch sometime tonight.
josetomax
Gnoblar
Posts: 2
Joined: Mon Nov 05, 2012 7:41 am

Re: iOS 6 GLES2 copyContentsToMemory returns all '\0'

Post by josetomax »

Thanks!

Please let me know when changes are available for download..
Chukytam
Gnoblar
Posts: 1
Joined: Fri Nov 23, 2012 11:06 am

Re: iOS 6 GLES2 copyContentsToMemory returns all '\0'

Post by Chukytam »

Hello!!

I have the same problem with iOS 6 and copyContentsToMemory. Is there any solution or changes in the last version of Ogre right now?

Thankss!
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: iOS 6 GLES2 copyContentsToMemory returns all '\0'

Post by masterfalcon »

Yes, there is a solution. See my comment a couple posts up about how to turn on retainedBacking.