iOS 使用 OpenGL ES 2.0 的 360 度视频

iOS 360 Video using OpenGL ES 2.0

我有一个应用程序使用 OpenGL ES 3.0 来播放 360 度全景视频,使用天空球体实现。我想使用 OpenGL ES 2.0 来支持更多设备。

在 ViewController.swift 中,我在方法 setupContext() 中创建了 EAGLContext,它与 .OpenGLES3 一起使用,但是当我尝试使用 .OpenGLES2 时,我只看到黑屏。没有错误消息,我无法辨别 OpenGL ES 2.0 不支持哪些 API 函数。

context = EAGLContext(API: .OpenGLES3)
EAGLContext.setCurrentContext(context)

如何使用 OpenGL ES 2.0 显示 360 度全景视频?主要实现在 Skysphere.swift 中。谢谢

示例应用可在此处找到:https://github.com/devinshively/TestVideoPlayer

问题是 OpenGL 3 会自动推断像素宽度和高度。要使用 OpenGL 2,我需要定义像素缓冲区属性 kCVPixelBufferWidthKey 和 kCVPixelBufferHeightKey。我用修复程序更新了测试库。

let pixelBufferAttributes = [kCVPixelBufferPixelFormatTypeKey as String : NSNumber(unsignedInt: kCVPixelFormatType_32BGRA),
                                       kCVPixelBufferWidthKey as String : 1024,
                                      kCVPixelBufferHeightKey as String : 512]