可以在EAGLLayer上使用Quartz 2D绘图吗?

时间:2023-02-09 08:39:13

In my app, I have an equalizer with a visualizer behind it.

在我的应用程序中,我有一个均衡器,后面有一个可视化器。

The equalizer is a series of dots which are imageviews with a path drawn between them using Quartz 2D (also with tick marks on the bottom and left to denote the frequency and gain amounts). Behind that is a visualizer done using OpenGL with a CAEAGLLayer.

均衡器是一系列点,它们是使用Quartz 2D在它们之间绘制的路径的图像视图(底部和左侧也带有刻度标记,表示频率和增益量)。其背后是使用OpenGL和CAEAGLLayer完成的可视化工具。

The way this is set up is there is a sub view of my view controller's main view that handles the visualizer, and above that is another subview of the main view that draws the path. Above both of them are the image views for the eq points.

设置方式是我的视图控制器主视图的子视图处理可视化器,上面是绘制路径的主视图的另一个子视图。以上两者都是eq点的图像视图。

What happens is, the path draws fine until a song starts and the visualizer starts to draw. It seems like it wipes out the Quartz 2D above it. Even having it call setNeedsDisplay on the view above it every time it draws is not working. Like OpenGL is given exclusive access to draw there. The UIImageView eq points however, stay visible.

会发生什么,路径一直播放,直到歌曲开始并且可视化器开始绘制。它似乎消灭了它上面的Quartz 2D。即使它每次绘制时都在它上面的视图上调用setNeedsDisplay也不起作用。像OpenGL一样可以在那里画画。然而,UIImageView eq指向,保持可见。

Is there any way to use Quartz 2D on top of a view with a gl layer? I'd prefer not to use OpenGL to draw the path and tick marks using OpenGL because I would have to draw to either a 512x512 or 1024x1024 texture and scale it, so it would not look perfect, and I've already got the working Quartz code to draw everything.

有没有办法在带有gl层的视图上使用Quartz 2D?我不想使用OpenGL来使用OpenGL绘制路径和刻度标记因为我必须绘制到512x512或1024x1024纹理并缩放它,所以它看起来不完美,我已经有了工作的Quartz绘制一切的代码。

1 个解决方案

#1


1  

Is there any way to use Quartz 2D on top of a view with a gl layer?

有没有办法在带有gl层的视图上使用Quartz 2D?

Yes, this is explicitly supported. The docs even give details on how to optimize drawing for this configuration.

是的,这是明确支持的。文档甚至提供了有关如何优化此配置的绘图的详细信息。

My suspicion is that your views are actually in the wrong order and the GL view is on top. First, make sure your GL view is marked opaque (for performance, but also because it will make it more obvious if it's in the wrong order). Then check your view ordering (check the main view's subviews).

我怀疑你的观点实际上是错误的顺序而GL观点是最重要的。首先,确保您的GL视图标记为不透明(为了提高性能,还因为如果它的顺序错误,它会更明显)。然后检查您的视图排序(检查主视图的子视图)。

#1


1  

Is there any way to use Quartz 2D on top of a view with a gl layer?

有没有办法在带有gl层的视图上使用Quartz 2D?

Yes, this is explicitly supported. The docs even give details on how to optimize drawing for this configuration.

是的,这是明确支持的。文档甚至提供了有关如何优化此配置的绘图的详细信息。

My suspicion is that your views are actually in the wrong order and the GL view is on top. First, make sure your GL view is marked opaque (for performance, but also because it will make it more obvious if it's in the wrong order). Then check your view ordering (check the main view's subviews).

我怀疑你的观点实际上是错误的顺序而GL观点是最重要的。首先,确保您的GL视图标记为不透明(为了提高性能,还因为如果它的顺序错误,它会更明显)。然后检查您的视图排序(检查主视图的子视图)。