我有一个简单的Swift命令行MacOS应用程序,我很难设置EAGLContext
let openGLContext = EAGLContext(API: .OpenGLES3)
let context = CIContext(EAGLContext: openGLContext)上面的代码给了我:
Use of unresolved identifier 'EAGLContext'不管我加载了什么模块:
import CoreImage
import OpenGL
import QuartzCore
import GLKit现在的问题是:CIContext默认使用OpenGL呈现吗?
当我初始化一个没有任何选项的新CIContext时:
let context = CIContext()并将env变量CI_PRINT_TREE设置为1控制台输出给我:
initial graph image_get_cgimage (opengl context 1 frame 1)
^^^^^^^^^^^^^^^^^^^^^^^^所以它会在GPU上下文中处理我的过滤器,对吗?是否有显式设置GPU呈现的方法,还是GPU是默认上下文?
发布于 2016-11-02 10:33:18
在可用的这里苹果文档中找到了答案
使用自动上下文进行呈现 如果您没有限制您的应用程序如何与其他图形技术交互,创建核心图像上下文很简单:只需使用基本的
init或initWithOptions:初始化器即可。这样做时,Core会自动管理内部资源,根据当前设备和指定的任何选项选择适当或最佳可用的CPU或GPU呈现技术。
发布于 2016-11-02 09:14:36
有一种方法可以显式地在CPU或GPU上初始化CIContext。
此外,还可以指定金属或OpenGL
为基于CPU的呈现创建上下文。
init(cgContext: CGContext, options: [String : Any]? = nil)使用指定的选项从Quartz上下文创建核心图像上下文。
使用OpenGL:为基于GPU的呈现创建上下文
init(cglContext: CGLContextObj, pixelFormat: CGLPixelFormatObj?, colorSpace: CGColorSpace?, options: [String : Any]? = nil)使用指定的选项、颜色空间和像素格式对象,从CGL上下文创建核心图像上下文。
init(eaglContext: EAGLContext)从EAGL上下文创建核心图像上下文。
init(eaglContext: EAGLContext, options: [String : Any]? = nil)使用指定的选项从EAGL上下文创建核心图像上下文。
init?(forOfflineGPUAt: UInt32)使用当前不驱动显示器的GPU创建基于OpenGL的核心图像上下文。
init?(forOfflineGPUAt: UInt32, colorSpace: CGColorSpace?, options: [String : Any]? = nil, sharedContext: CGLContextObj?)使用当前不驱动显示器的GPU创建一个基于OpenGL的核心图像上下文,并具有指定的选项。
为基于GPU的金属渲染创建上下文
init(mtlDevice: MTLDevice)使用指定的金属设备创建核心图像上下文。
init(mtlDevice: MTLDevice, options: [String : Any]? = nil)使用指定的金属设备和选项创建核心图像上下文。
https://stackoverflow.com/questions/40375998
复制相似问题