当任何游戏与opengl一起运行时,我想要捕获屏幕 [英] I want capture screen when any game is running with opengl

查看:115
本文介绍了当任何游戏与opengl一起运行时,我想要捕获屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:


\\ n-in-code-in-ios-6-0


我正在使用OpenGL开发一款游戏,拍摄最佳镜头时需要一个屏幕截图并上传facebook但是当我拍摄屏幕时它只有黑屏。我所做的 ?
我还在链接中使用代码:
以编程方式获取UIview + glview的屏幕
和类似代码
但没有成功。

I am developing a game with OpenGL, need a screen shot when best shot taken and upload facebook but when i take screen shot its only black screen. what i do ? I also use code in link : take screen Programmatically of UIview+glview and similar code but no success.

我起诉代码来自: http://developer.apple.com/library/ios/#qa/qa1704/_index.html

但是所有代码结果模拟器中的图像不在设备中(在设备中只有黑色或白色)

But All code result an image in simulator not in device(in device only black or white)

推荐答案

试试这个会截取视图和保存到设备相册。

Try this this will take screenshot of view and save into device photo album.

-(IBAction)captureScreen:(id)sender
{
    UIGraphicsBeginImageContext(self.view.bounds.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *snapImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageWriteToSavedPhotosAlbum(snapImage, nil, nil, nil);
}

这篇关于当任何游戏与opengl一起运行时,我想要捕获屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆