- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 FFMPEG 创建一个播放器,该播放器可以使用 OpenGL 显示帧。 player
类有三个线程:一个用于渲染(运行一个 runloop 并处理每 N 毫秒触发的渲染事件。) - 它获取 GLKTextureInfo
存储在图片队列中并渲染。
第一个用于从 VideoStream 中读取数据包并将它们放入 videoQueue,第三个用于从 videoQueue 中获取数据包并对其进行解码并创建一个 GLKTextureInfo
并将其存储在图片队列中。
案例一:player
类子类 GLKView
并创建一个 EAGLContext
将其设置为其上下文,并在渲染线程中设置为 currentContext(它是第一个启动的线程)。
EAGLContext *mycontext = [self createBestEaglContext];
if (!self.mycontext || ![EAGLContext setCurrentContext:mycontext]) {
NSLog(@"Could not create Base EAGLContext");
return;
}
[self setContext:mycontext];
stream decoding thread
进而启动
Video Packet Decoding Thread
如果它找到一个视频流。那么
// set's the params for the GLKBaseEffect
// set's up VBO's
// run's runloop
Video Packet Decoding Thread
还创建
EAGLContext
共享先前创建的上下文
EAGLSharegroup
.
self.videoPacketDecodeThreadContext = [self createEaglContextForOtherThread];
if (!self.videoPacketDecodeThreadContext || ![EAGLContext setCurrentContext:self.videoPacketDecodeThreadContext])
{
NSLog(@"Could not create video packet decode thread context");
}
UIImage* image = [self ImageFromAVPicture:*(AVPicture*)pFrameRGB width:self.is.video_stream->codec->width height:self.is.video_stream->codec->height];
NSError *error = nil;
GLKTextureInfo *textureInfo = [GLKTextureLoader textureWithCGImage:image.CGImage
options:nil
error:&error];
if (error)
{
NSLog(@"Texture loading Error: %@\n", error.description);
//return -1;
}
else
{
[self.is.pictQueue_lock lock];
[self.is.pictQueue enqueue:textureInfo];
[self.is.pictQueue_lock unlock];
}
Failed to bind EAGLDrawable: <CAEAGLLayer: 0x156f7e50> to GL_RENDERBUFFER 1
和
Failed to make complete framebuffer object 8cd6
和
glerror 1280
.
Player
不子类
GLKView
相反,它被设置为
GLKView
的委托(delegate)。在 Storyboard 中创建。
-(void)initPlayerWithView:(GLKView*)v
{
self.view = v;
}
self.view
上下文设置为
mycontext
)一切运行良好。
-(void)drawRect:(CGRect)rect
和
-(void)glkView:(GLKView *)view drawInRect:(CGRect)rect
都在
Rendering Thread
上调用.渲染代码:
{
[self.is.pictQueue_lock lock];
GLKTextureInfo *textureInfo = (GLKTextureInfo*)[self.is.pictQueue dequeue];
[self.is.pictQueue_lock unlock];
// delete the previous texture
GLuint index = self.baseEffect.texture2d0.name;
glDeleteTextures(1, &index);
self.baseEffect.texture2d0.name = textureInfo.name;
self.baseEffect.texture2d0.target = textureInfo.target;
[self.baseEffect prepareToDraw];
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// Enable vertex buffer
glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
glEnableVertexAttribArray(GLKVertexAttribPosition);
//Enable texture buffer
glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (GLvoid*)offsetof(Vertex, textureCoords));
glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
glDrawElements(GL_TRIANGLES, sizeof(Indices)/sizeof(Indices[0]), GL_UNSIGNED_BYTE, 0);
}
最佳答案
我不关心 GLKView,我在 OSX 中使用 NSOpenGLView 编写了一个播放器,子类化在那里工作得很好,但我让它为我创建上下文。
Am i using to many threads ?
I am converting the decoded frame to a UIImage and then creating a texture from it. can it be done differently ?
关于ios - EAGLContexts 共享 EAGLSharegroup 在子类化 GLKView 时给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32247957/
我的应用程序有几个不同的 OpenGL 上下文,都使用同一组着色器。目前它会多次重新编译、链接等着色器,每个上下文一次。我正在尝试加快速度,遇到了 EAGLSharegroup。 documentat
我正在尝试了解 iPhone 操作系统上的 OpenGL 对象模型。我当前正在屏幕上渲染到几个不同的 UIView(基于 CAEAGLayer 构建)。我目前将其中每一个都使用单独的 EAGLCont
我正在尝试使用 FFMPEG 创建一个播放器,该播放器可以使用 OpenGL 显示帧。 player类有三个线程:一个用于渲染(运行一个 runloop 并处理每 N 毫秒触发的渲染事件。) - 它获
我是一名优秀的程序员,十分优秀!