是否可以使OpenGL ES层透明? [英] Is it possible to make an OpenGL ES layer transparent?

查看:472
本文介绍了是否可以使OpenGL ES层透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使OpenGL ES图层的背景透明,以便您可以看到OpenGL ES内容背后的内容?

Is it possible to make the background of an OpenGL ES layer transparent so you can see what is behind the OpenGL ES content?

推荐答案

你必须做两件事:


  1. 初始化CAEAGLLayer时,将opaque属性设置为NO(或FALSE)。



    您可能还需要确保drawableProperties使用颜色格式支持透明度(kEAGLColorFormatRGBA8确实,但kEAGLColorFormatRGB565不)



    eaglLayer.opaque = NO; <无线电通信/>


    eaglLayer.drawableProperties = [NSDictionary的dictionaryWithObjectsAndKeys:[NSNumber的numberWithBool:否],kEAGLDrawablePropertyRetainedBacking,kEAGLColorFormatRGBA8,kEAGLDrawablePropertyColorFormat,零];



    如果您使用的是XCode的OpenGL项目模板,这将在[EAGLView的initWithCoder]中。




  2. 以透明色和alpha画出背景。



    glClearColor(0.0f,0.0f,0.0f,0.0f);
    $


    如果你是使用XCode的OpenGL项目模板,这将是渲染方法:[ES1Renderer渲染]和[ES2Renderer渲染]。

  1. When you initialize your CAEAGLLayer, set the opaque property to NO (or FALSE).

    You may also need to make sure your drawableProperties uses a color format that supports transparency (kEAGLColorFormatRGBA8 does, but kEAGLColorFormatRGB565 does not).

    eaglLayer.opaque = NO;

    eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];

    If you are using XCode's OpenGL project template, this will be in [EAGLView's initWithCoder].

  2. Draw the background in a transparent color and alpha.

    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

    If you are using XCode's OpenGL project template, this will be in the "render" methods: [ES1Renderer render] and [ES2Renderer render].

这篇关于是否可以使OpenGL ES层透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆