I'm trying to make an screenshot to save it in an UIImage and store in the photo album, but i'm dealing with tons of problems.
First of all, I need to have the viewport rotations locked, i never call the function setNeedsLayout, but i dont know if this is enough or ogre internally takes care about orientations....
After all, the moment to take the screenshot arrives. If i start ogre with portrait orientation, all runs "well", i can make an screenshot (although its vertically flipped), even if i rotate the phone the photos are right taken.
But if i start the app in other orientation mode "Landscape Left" or "Landscape Right" (specified in ogre.cfg) the images are broken. Although i'm in landscape, the image is created with 480x320 but the function copyContentsToMemory returns a portrait image with a 160 white pixels (i'm running in 3Gs with 480x320) at right, of course the image is cut in the bottom (is like if the copyContentsToMemory always returns a 320x480 image...). I've tried to swap witdh and height, but i get crashes or malformed images (with white pixels also!). Even, if I run in landscape mode, and move the phone to portrait, then the image is all white.
Plus, sometimes, when i push the screenshot button, the whole image is white! can be any kind of threading problem?
Here is the code where i call the function, this code has been changed several times:
Code: Select all
int left, top, width, height;
m_pOgreViewport->getActualDimensions(left, top, width, height);
Ogre::PixelFormat format = Ogre::PF_BYTE_RGBA;
outWidth = width;
outHeight = height;
outBytesPerPixel = Ogre::PixelUtil::getNumElemBytes(format);
printf("Left %d, Top %d, Width: %d, Height: %d\n", left, top, width, height);
unsigned char *data = new unsigned char [outWidth*outHeight*outBytesPerPixel];
//Ogre::PixelBox box = Ogre::PixelBox(outWidth, outHeight, 1, format, data);
//m_pOgreRenderWnd->copyContentsToMemory(box);
//Ogre::uchar *data = OGRE_ALLOC_T(Ogre::uchar, width * height * outBytesPerPixel, Ogre::MEMCATEGORY_RENDERSYS);
Ogre::Box extents(left, top, left + width, top + height);
Ogre::PixelBox pb(extents, format, data);
printf("PixelBox: %d, %d, w: %d, h: %d\n", pb.left, pb.right, pb.getWidth(), pb.getHeight());
m_pOgreRenderWnd->copyContentsToMemory(pb);Any ideas?2011-08-02 11:36:42.521 Ogre[546:307] **** Taking screenshot
Left 0, Top 0, Width: 480, Height: 320
PixelBox: 0, 480, w: 480, h: 320
Assertion failed: (_Unwind_SjLj_Resume() can't return), function _Unwind_SjLj_Resume, file /SourceCache/libunwind/libunwind-24.1/src/Unwind-sjlj.c, line 326.
Program received signal: “SIGABRT”.
I'm running in IPhone 3Gs, Ogre 1.7.3, iOS SDK 4.3, target platform 4.1, compiling for device, and device running iOS 4.2.1.
Thanks in advance!
PS: Ogre.log in landscape right
Code: Select all
Creating resource group General
Creating resource group Internal
Creating resource group Autodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
OverlayElementFactory for type Panel registered.
OverlayElementFactory for type BorderPanel registered.
OverlayElementFactory for type TextArea registered.
Registering ResourceManager for type Font
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
DDS codec registering
FreeImage version: 3.15.0
This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
Supported formats: jpg,jif,jpeg,jpe,png,tga,targa,tif,tiff
PVRTC codec registering
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
*-*-* OGRE Initialising
*-*-* Version 1.7.3 (Cthugha)
Installing plugin: OpenGL ES 1.x RenderSystem
OpenGL ES 1.x Rendering Subsystem created.
Plugin successfully installed
CPU Identifier & Features
-------------------------
* CPU ID: ARMv7
* VFP: no
* NEON: yes
-------------------------
GLESRenderSystem::_createRenderWindow "Test", 320x480 fullscreen miscParams: FSAA=4x contentScalingFactor=1 displayFrequency=0 Hz orientation=Landscape Right
iOS: Window created 320 x 480 with backing store size 320 x 480 using content scaling factor 1.0
GL_VERSION = OpenGL ES-CM 1.1 IMGSGX535-48.20
GL_VENDOR = Imagination Technologies
GL_RENDERER = PowerVR SGX 535
GL_EXTENSIONS = GL_APPLE_framebuffer_multisample GL_APPLE_texture_2D_limited_npot GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_EXT_read_format_bgra GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_IMG_read_format GL_IMG_texture_compression_pvrtc GL_OES_blend_equation_separate GL_OES_blend_func_separate GL_OES_blend_subtract GL_OES_compressed_paletted_texture GL_OES_depth24 GL_OES_draw_texture GL_OES_fbo_render_mipmap GL_OES_framebuffer_object GL_OES_mapbuffer GL_OES_matrix_palette GL_OES_packed_depth_stencil GL_OES_point_size_array GL_OES_point_sprite GL_OES_read_format GL_OES_rgb8_rgba8 GL_OES_stencil8 GL_OES_stencil_wrap GL_OES_texture_mirrored_repeat GL_OES_vertex_array_object
EXT:GL_APPLE_framebuffer_multisample
EXT:GL_APPLE_texture_2D_limited_npot
EXT:GL_APPLE_texture_format_BGRA8888
EXT:GL_APPLE_texture_max_level
EXT:GL_EXT_blend_minmax
EXT:GL_EXT_discard_framebuffer
EXT:GL_EXT_read_format_bgra
EXT:GL_EXT_texture_filter_anisotropic
EXT:GL_EXT_texture_lod_bias
EXT:GL_IMG_read_format
EXT:GL_IMG_texture_compression_pvrtc
EXT:GL_OES_blend_equation_separate
EXT:GL_OES_blend_func_separate
EXT:GL_OES_blend_subtract
EXT:GL_OES_compressed_paletted_texture
EXT:GL_OES_depth24
EXT:GL_OES_draw_texture
EXT:GL_OES_fbo_render_mipmap
EXT:GL_OES_framebuffer_object
EXT:GL_OES_mapbuffer
EXT:GL_OES_matrix_palette
EXT:GL_OES_packed_depth_stencil
EXT:GL_OES_point_size_array
EXT:GL_OES_point_sprite
EXT:GL_OES_read_format
EXT:GL_OES_rgb8_rgba8
EXT:GL_OES_stencil8
EXT:GL_OES_stencil_wrap
EXT:GL_OES_texture_mirrored_repeat
EXT:GL_OES_vertex_array_object
**************************************
*** OpenGL ES 1.x Renderer Started ***
**************************************
Registering ResourceManager for type GpuProgram
GL ES: Using GL_OES_framebuffer_object for rendering to textures (best)
FBO PF_UNKNOWN depth/stencil support: D16S0 D24S0 Packed-D24S8
FBO PF_R5G6B5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_B5G6R5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_A4R4G4B4 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_A1R5G5B5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_B8G8R8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_A8R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_X8R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_X8B8G8R8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
[GLES] : Valid FBO targets PF_UNKNOWN PF_R5G6B5 PF_B5G6R5 PF_A4R4G4B4 PF_A1R5G5B5 PF_R8G8B8 PF_B8G8R8 PF_A8R8G8B8 PF_X8R8G8B8 PF_X8B8G8R8
RenderSystem capabilities
-------------------------
RenderSystem Name: OpenGL ES 1.x Rendering Subsystem
GPU Vendor: imagination technologies
Device Name: PowerVR SGX 535
Driver Version: 0.0.0.0
* Fixed function pipeline: yes
* Hardware generation of mipmaps: yes
* Texture blending: yes
* Anisotropic texture filtering: yes
* Dot product texture operation: yes
* Cube mapping: no
* Hardware stencil buffer: no
* Hardware vertex / index buffers: yes
* Vertex programs: no
* Number of floating-point constants for vertex programs: 0
* Number of integer constants for vertex programs: 0
* Number of boolean constants for vertex programs: 0
* Fragment programs: no
* Number of floating-point constants for fragment programs: 0
* Number of integer constants for fragment programs: 0
* Number of boolean constants for fragment programs: 0
* Geometry programs: no
* Number of floating-point constants for geometry programs: 0
* Number of integer constants for geometry programs: 0
* Number of boolean constants for geometry programs: 0
* Supported Shader Profiles:
* Texture Compression: yes
- DXT: no
- VTC: no
- PVRTC: yes
* Scissor Rectangle: yes
* Hardware Occlusion Query: no
* User clip planes: yes
* VET_UBYTE4 vertex element type: yes
* Infinite far plane projection: yes
* Hardware render-to-texture: yes
* Floating point textures: no
* Non-power-of-two textures: no
* Volume textures: no
* Multiple Render Targets: 1
- With different bit depths: no
* Point Sprites: yes
* Extended point parameters: yes
* Max Point Size: 511
* Vertex texture fetch: no
* Number of world matrices: 0
* Number of texture units: 8
* Stencil buffer depth: 0
* Number of vertex blend matrices: 0
* Render to Vertex Buffer : no
* GL 1.5 without VBO workaround: no
* Frame Buffer objects: yes
* Frame Buffer objects (ARB extension): no
* Frame Buffer objects (ATI extension): no
* PBuffer support: no
* GL 1.5 without HW-occlusion workaround: no
Registering ResourceManager for type Texture
DefaultWorkQueue('Root') initialising on thread 0x83f930.
DefaultWorkQueue('Root')::WorkerFunc - thread 0x845b40 starting.
Particle Renderer Type 'billboard' registered
****** BundlePath /var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app
Creating resource group Bootstrap
Added resource location '/var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app/./OgreCore.zip' of type 'Zip' to resource group 'Bootstrap'
Added resource location '/var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app/.' of type 'FileSystem' to resource group 'General'
Added resource location '/var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app/./media' of type 'FileSystem' to resource group 'General'
Added resource location '/var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app/./media/materials' of type 'FileSystem' to resource group 'General'
Added resource location '/var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app/./media/models' of type 'FileSystem' to resource group 'General'
Parsing scripts for resource group Autodetect
Finished parsing scripts for resource group Autodetect
Parsing scripts for resource group Bootstrap
Parsing script OgreCore.material
Parsing script OgreProfiler.material
Parsing script Ogre.fontdef
Parsing script OgreDebugPanel.overlay
Texture: New_Ogre_Border_Center.png: Loading 1 faces(PF_A8B8G8R8,256x128x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x128x1.
Texture: New_Ogre_Border.png: Loading 1 faces(PF_A8B8G8R8,256x256x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x256x1.
Texture: New_Ogre_Border_Break.png: Loading 1 faces(PF_A8B8G8R8,32x32x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
Texture: ogretext.png: Loading 1 faces(PF_A8B8G8R8,256x128x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x128x1.
Parsing script OgreLoadingPanel.overlay
Finished parsing scripts for resource group Bootstrap
Parsing scripts for resource group General
Parsing script Ogre.material
Parsing script barco.material
Finished parsing scripts for resource group General
Parsing scripts for resource group Internal
Finished parsing scripts for resource group InternalCode: Select all
Creating resource group General
Creating resource group Internal
Creating resource group Autodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
OverlayElementFactory for type Panel registered.
OverlayElementFactory for type BorderPanel registered.
OverlayElementFactory for type TextArea registered.
Registering ResourceManager for type Font
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
DDS codec registering
FreeImage version: 3.15.0
This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
Supported formats: jpg,jif,jpeg,jpe,png,tga,targa,tif,tiff
PVRTC codec registering
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
*-*-* OGRE Initialising
*-*-* Version 1.7.3 (Cthugha)
Installing plugin: OpenGL ES 1.x RenderSystem
OpenGL ES 1.x Rendering Subsystem created.
Plugin successfully installed
CPU Identifier & Features
-------------------------
* CPU ID: ARMv7
* VFP: no
* NEON: yes
-------------------------
GLESRenderSystem::_createRenderWindow "Test", 320x480 fullscreen miscParams: FSAA=4x contentScalingFactor=1 displayFrequency=0 Hz orientation=Portrait
iOS: Window created 320 x 480 with backing store size 320 x 480 using content scaling factor 1.0
GL_VERSION = OpenGL ES-CM 1.1 IMGSGX535-48.20
GL_VENDOR = Imagination Technologies
GL_RENDERER = PowerVR SGX 535
GL_EXTENSIONS = GL_APPLE_framebuffer_multisample GL_APPLE_texture_2D_limited_npot GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_EXT_read_format_bgra GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_IMG_read_format GL_IMG_texture_compression_pvrtc GL_OES_blend_equation_separate GL_OES_blend_func_separate GL_OES_blend_subtract GL_OES_compressed_paletted_texture GL_OES_depth24 GL_OES_draw_texture GL_OES_fbo_render_mipmap GL_OES_framebuffer_object GL_OES_mapbuffer GL_OES_matrix_palette GL_OES_packed_depth_stencil GL_OES_point_size_array GL_OES_point_sprite GL_OES_read_format GL_OES_rgb8_rgba8 GL_OES_stencil8 GL_OES_stencil_wrap GL_OES_texture_mirrored_repeat GL_OES_vertex_array_object
EXT:GL_APPLE_framebuffer_multisample
EXT:GL_APPLE_texture_2D_limited_npot
EXT:GL_APPLE_texture_format_BGRA8888
EXT:GL_APPLE_texture_max_level
EXT:GL_EXT_blend_minmax
EXT:GL_EXT_discard_framebuffer
EXT:GL_EXT_read_format_bgra
EXT:GL_EXT_texture_filter_anisotropic
EXT:GL_EXT_texture_lod_bias
EXT:GL_IMG_read_format
EXT:GL_IMG_texture_compression_pvrtc
EXT:GL_OES_blend_equation_separate
EXT:GL_OES_blend_func_separate
EXT:GL_OES_blend_subtract
EXT:GL_OES_compressed_paletted_texture
EXT:GL_OES_depth24
EXT:GL_OES_draw_texture
EXT:GL_OES_fbo_render_mipmap
EXT:GL_OES_framebuffer_object
EXT:GL_OES_mapbuffer
EXT:GL_OES_matrix_palette
EXT:GL_OES_packed_depth_stencil
EXT:GL_OES_point_size_array
EXT:GL_OES_point_sprite
EXT:GL_OES_read_format
EXT:GL_OES_rgb8_rgba8
EXT:GL_OES_stencil8
EXT:GL_OES_stencil_wrap
EXT:GL_OES_texture_mirrored_repeat
EXT:GL_OES_vertex_array_object
**************************************
*** OpenGL ES 1.x Renderer Started ***
**************************************
Registering ResourceManager for type GpuProgram
GL ES: Using GL_OES_framebuffer_object for rendering to textures (best)
FBO PF_UNKNOWN depth/stencil support: D16S0 D24S0 Packed-D24S8
FBO PF_R5G6B5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_B5G6R5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_A4R4G4B4 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_A1R5G5B5 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_B8G8R8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_A8R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_X8R8G8B8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
FBO PF_X8B8G8R8 depth/stencil support: D0S0 D0S8 D16S0 D24S0 Packed-D24S8
[GLES] : Valid FBO targets PF_UNKNOWN PF_R5G6B5 PF_B5G6R5 PF_A4R4G4B4 PF_A1R5G5B5 PF_R8G8B8 PF_B8G8R8 PF_A8R8G8B8 PF_X8R8G8B8 PF_X8B8G8R8
RenderSystem capabilities
-------------------------
RenderSystem Name: OpenGL ES 1.x Rendering Subsystem
GPU Vendor: imagination technologies
Device Name: PowerVR SGX 535
Driver Version: 0.0.0.0
* Fixed function pipeline: yes
* Hardware generation of mipmaps: yes
* Texture blending: yes
* Anisotropic texture filtering: yes
* Dot product texture operation: yes
* Cube mapping: no
* Hardware stencil buffer: no
* Hardware vertex / index buffers: yes
* Vertex programs: no
* Number of floating-point constants for vertex programs: 0
* Number of integer constants for vertex programs: 0
* Number of boolean constants for vertex programs: 0
* Fragment programs: no
* Number of floating-point constants for fragment programs: 0
* Number of integer constants for fragment programs: 0
* Number of boolean constants for fragment programs: 0
* Geometry programs: no
* Number of floating-point constants for geometry programs: 0
* Number of integer constants for geometry programs: 0
* Number of boolean constants for geometry programs: 0
* Supported Shader Profiles:
* Texture Compression: yes
- DXT: no
- VTC: no
- PVRTC: yes
* Scissor Rectangle: yes
* Hardware Occlusion Query: no
* User clip planes: yes
* VET_UBYTE4 vertex element type: yes
* Infinite far plane projection: yes
* Hardware render-to-texture: yes
* Floating point textures: no
* Non-power-of-two textures: no
* Volume textures: no
* Multiple Render Targets: 1
- With different bit depths: no
* Point Sprites: yes
* Extended point parameters: yes
* Max Point Size: 511
* Vertex texture fetch: no
* Number of world matrices: 0
* Number of texture units: 8
* Stencil buffer depth: 0
* Number of vertex blend matrices: 0
* Render to Vertex Buffer : no
* GL 1.5 without VBO workaround: no
* Frame Buffer objects: yes
* Frame Buffer objects (ARB extension): no
* Frame Buffer objects (ATI extension): no
* PBuffer support: no
* GL 1.5 without HW-occlusion workaround: no
Registering ResourceManager for type Texture
DefaultWorkQueue('Root') initialising on thread 0x839290.
DefaultWorkQueue('Root')::WorkerFunc - thread 0x83f2a0 starting.
Particle Renderer Type 'billboard' registered
****** BundlePath /var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app
Creating resource group Bootstrap
Added resource location '/var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app/./OgreCore.zip' of type 'Zip' to resource group 'Bootstrap'
Added resource location '/var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app/.' of type 'FileSystem' to resource group 'General'
Added resource location '/var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app/./media' of type 'FileSystem' to resource group 'General'
Added resource location '/var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app/./media/materials' of type 'FileSystem' to resource group 'General'
Added resource location '/var/mobile/Applications/7C15F3BA-EE0B-435D-9638-8EB576A206FB/Ogre.app/./media/models' of type 'FileSystem' to resource group 'General'
Parsing scripts for resource group Autodetect
Finished parsing scripts for resource group Autodetect
Parsing scripts for resource group Bootstrap
Parsing script OgreCore.material
Parsing script OgreProfiler.material
Parsing script Ogre.fontdef
Parsing script OgreDebugPanel.overlay
Texture: New_Ogre_Border_Center.png: Loading 1 faces(PF_A8B8G8R8,256x128x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x128x1.
Texture: New_Ogre_Border.png: Loading 1 faces(PF_A8B8G8R8,256x256x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x256x1.
Texture: New_Ogre_Border_Break.png: Loading 1 faces(PF_A8B8G8R8,32x32x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,32x32x1.
Texture: ogretext.png: Loading 1 faces(PF_A8B8G8R8,256x128x1) with 5 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x128x1.
Parsing script OgreLoadingPanel.overlay
Finished parsing scripts for resource group Bootstrap
Parsing scripts for resource group General
Parsing script Ogre.material
Parsing script barco.material
Finished parsing scripts for resource group General
Parsing scripts for resource group Internal
Finished parsing scripts for resource group Internal