是否可以在UIView上放置一个OpenGL ES渲染视图,而UIView发光就像OpenGL ES是一个有透明度的PNG? [英] Is it possible to put an OpenGL ES rendering view over an UIView, while the UIView shines through like if the OpenGL ES was a PNG with transparency?

查看:162
本文介绍了是否可以在UIView上放置一个OpenGL ES渲染视图,而UIView发光就像OpenGL ES是一个有透明度的PNG?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道,但如果这是可能的(例如Flash),那将是非常酷。

I have no idea about it, but if that was possible (like Flash, for example), then that would be really cool.

我有一个view-基于应用程序,我需要一些OpenGL ES功能,但不想要全屏的OpenGL ES。

I have an view-based app where I need probably some OpenGL ES capabilities, but don't want to have fullscreen OpenGL ES. I just need it at certain small areas for drawing little charts and other stuff that may be hard to do with core graphics.

推荐答案

我们只需要在某些小区域绘制小图表和其他可能难以处理核心图形的东西。是的,

Yes,

您应该能够通过Quartz Core使用图层来实现它(请参阅CALayer类文档)。事实上,你可以有层次结构。基本上,您将每个UIView关联到不同的图层,然后将这些图层一起渲染,提供一个单一的复合图层。此外,您还可以对图层应用变换和动画。

you should be able to implement this through Quartz Core using layers (see the CALayer class documentation). Indeed, you can have layers hierarchies. Basically you associate each UIView to a different layer, then the layers are rendered together providing a single, composite layer. Besides, you can also apply transforms and animations to layers.

您需要导入QuartzCore头并执行类似

You need to import the QuartzCore header and do something like

#import <QuartzCore/QuartzCore.h>
UIView *myView = [[UIView alloc] initWithFrame...
UIView *openGLView = [UIView alloc] initWithFrame...

CaLayer *myViewLayer = myView.layer;
[myViewLayer addSubLayer: openGLView.layer];

然后,当myView出现在屏幕上时,所有子图层都合并在一起,并在屏幕上呈现。会发生什么是每个视图呈现其图层,而myViewLayer渲染合并在一起的两个图层。

Then, when myView appears on the screen, all the sublayers are merged together and rendered on screen. What happens is that each view renders its layer, while myViewLayer is rendered merging together the two layers.

您可以拥有任意数量的图层。

You can have as many layers as you like. You can create an arbitrary hierarchi by using the CALayer methods

- addSublayer:
- removeFromSuperlayer

- insertSublayer:atIndex:

- insertSublayer:below:

- insertSublayer:above:

- replaceSublayer:with:

– addSublayer: – removeFromSuperlayer
– insertSublayer:atIndex:
– insertSublayer:below:
– insertSublayer:above:
– replaceSublayer:with:

这篇关于是否可以在UIView上放置一个OpenGL ES渲染视图,而UIView发光就像OpenGL ES是一个有透明度的PNG?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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