iPhone:在 UIView 之上分层透明的 openGL 视图? [英] iPhone: Layering a transparent openGL view on top of a UIView?
问题描述
我正在开发 iPhone 应用程序,并且在常规 UIView 之上有一个 openGL 视图渲染.它正在工作,但我似乎无法让 openGL 视图具有显示下方 UIView 的透明背景.相反,我得到了一个大黑匣子.
I am working on iPhone app and I have an openGL view rendering on top of a regular UIView. It's working, but I can't seem to get the openGL view to have a transparent background that shows the UIView underneath. Instead, I get a big black box.
我已经尝试将背景颜色设置为 UIColor clearColor,我已将 opaque 设置为 NO,我已将 glClearColor 设置为 0.0,0.0,0.0,0.0.
I have tried setting the background color to UIColor clearColor, I've set opaque to NO, I've set glClearColor to 0.0,0.0,0.0,0.0.
我认为我误解/误用了与混合模式相关的内容,但我不确定.谁能给我一些示例代码来展示如何做到这一点?
I think I'm misunderstanding/misusing something related to blend modes, but I'm not sure. Can anyone give me a bit of sample code which shows how to do this?
提前致谢.
推荐答案
这是我必须做的事情才能让它发挥作用:
Here's what I had to do to get this to work:
eaglLayer.opaque = NO;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
如果你正在做我正在做的事情并试图用 GLGravity 演示来测试它,还有另一个调用 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
每次 drawView
被调用时——所以确保你也将它更改为 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
!:)
And incase you're doing what I was doing and are trying to test it with the GLGravity demo, there's another call to glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
every time drawView
is called -- so make sure you change that one to glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
too! :)
这篇关于iPhone:在 UIView 之上分层透明的 openGL 视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!