简体   繁体   English

使用OpenGL ES 2.0的iOS 360视频

[英]iOS 360 Video using OpenGL ES 2.0

I have an app that uses OpenGL ES 3.0 to play 360 Videos using a sky sphere implementation. 我有一个使用OpenGL ES 3.0的应用程序,可使用天空球体实现播放360视频。 I want to use OpenGL ES 2.0 to support more devices. 我想使用OpenGL ES 2.0支持更多设备。

In ViewController.swift I create the EAGLContext in the method setupContext() and it works with .OpenGLES3 but when I try to use .OpenGLES2 I only see a black screen. 在ViewController.swift中,我在setupContext()方法中创建EAGLContext,并且它与.OpenGLES3一起使用,但是当我尝试使用.OpenGLES2时,我只会看到黑屏。 There are no error messages and I am unable to discern what API functions are not supported in OpenGL ES 2.0. 没有错误消息,我无法确定OpenGL ES 2.0中不支持哪些API函数。

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

How can I use OpenGL ES 2.0 to display 360 videos using a sky sphere? 如何使用OpenGL ES 2.0使用天空球显示360个视频? The main implementation is in Skysphere.swift. 主要实现在Skysphere.swift中。 Thanks. 谢谢。

Sample app is found here: https://github.com/devinshively/TestVideoPlayer 示例应用程序位于此处: https : //github.com/devinshively/TestVideoPlayer

The issue was that OpenGL 3 automatically infers the pixel width and height. 问题是OpenGL 3自动推断像素的宽度和高度。 To use OpenGL 2 I needed to define the pixel buffer attributes kCVPixelBufferWidthKey and kCVPixelBufferHeightKey. 要使用OpenGL 2,我需要定义像素缓冲区属性kCVPixelBufferWidthKey和kCVPixelBufferHeightKey。 I updated the test repo with the fix. 我用修复程序更新了测试仓库。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM