可能重複:
OpenGL Layer on top of Video on iPhone?如何在iPhone的攝像頭視頻上方繪製OpenGL ES上下文?
我想提請以上攝像機的視頻部分的OpenGL ES上下文的iOS 4
我使用蘋果本教程以獲得來自相機的視頻幀: http://developer.apple.com/library/ios/#qa/qa2010/qa1702.html
工程就像一個魅力。我可以從相機獲取視頻幀並顯示它們。
但是 - 我想在視頻上方顯示一些OpenGL ES繪圖。這個背景應該有一個透明的背景,並且只顯示我繪製的內容。
用於顯示視頻的代碼:
AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:session1];
的UIView * aView = [自視圖]。 previewLayer.frame = aView.bounds; //假設您希望預覽圖層填充視圖。 [aView.layer addSublayer:previewLayer];
用於顯示OpenGL繪圖的代碼:
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
[上下文presentRenderbuffer:GL_RENDERBUFFER_OES];
問題是 - 我只能繪製一個完整的OpenGL圖層(意思是背景爲黑色),並且不僅可以繪製一些帶有透明背景的opengl工件(以便用戶可以在opengl下面看到視頻上下文)。
非常感謝, fiod