检查GPUImage的设备类型 [英] Check Device Type For GPUImage

查看:84
本文介绍了检查GPUImage的设备类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于iPhone 4及以下版本,GPUImage需要小于2048像素的图像. 4S及更高版本可以处理更大的内容.如何查看我的应用当前正在哪个设备上运行?我没有在UIDevice中找到任何符合我所要查找的内容.有任何建议/解决方法吗?

GPUImage requires, for iPhone 4 and below, images smaller than 2048 pixels. The 4S and above can handle much larger. How can I check to see which device my app is currently running on? I haven't found anything in UIDevice that does what I'm looking for. Any suggestions/workarounds?

推荐答案

为此,您无需检查设备类型,只需要读取设备支持的最大纹理大小即可.幸运的是,GPUImage中有一个内置方法可以为您做到这一点:

For this, you don't need to check device type, you simply need to read the maximum texture size supported by the device. Luckily, there is a built-in method within GPUImage that does this for you:

GLint maxTextureSize = [GPUImageContext maximumTextureSizeForThisDevice]; 

以上内容将为您提供在其上运行设备的最大纹理大小.这将决定GPUImage可以在该设备上使用的最大图像大小,并且对于以后出现的所有iOS设备都应具有前瞻性.

The above will give you the maximum texture size for the device you're running this on. That will determine the largest image size that GPUImage can work with on that device, and should be future-proof against whatever iOS devices come next.

此方法通过缓存此OpenGL ES查询的结果而起作用:

This method works by caching the results of this OpenGL ES query:

 glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);

如果您好奇的话.

我还要注意,您可以为框架提供大于最大纹理大小的图像,但是在处理之前,它们会缩小到GPU支持的最大大小.在某个时候,我可能会完成在处理中平铺这些图像的各个部分的计划,以便可以本地支持更大的图像.不过,这还很遥远.

I should also note that you can provide images larger than the max texture size to the framework, but they get scaled down to the largest size supported by the GPU before processing. At some point, I may complete my plan for tiling subsections of these images in processing so that larger images can be supported natively. That's a ways off, though.

这篇关于检查GPUImage的设备类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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