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

发布于 2024-12-29 07:47:49 字数 516 浏览 3 评论 0原文

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

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

设置的方式是我的视图控制器的主视图有一个处理可视化工具的子视图,在其上方是绘制路径的主视图的另一个子视图。它们上方是 eq 点的图像视图。

发生的情况是,路径绘制得很好,直到歌曲开始并且可视化工具开始绘制。看起来它消灭了上面的 Quartz 2D。即使每次绘制时都在其上方的视图上调用 setNeedsDisplay 也是行不通的。就像 OpenGL 被赋予在那里进行绘制的独占访问权一样。然而,UIImageView eq 点保持可见。

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

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.

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.

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜声 2025-01-05 07:47:49

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

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

我怀疑你的视图实际上顺序错误,GL 视图位于顶部。首先,确保您的 GL 视图被标记为不透明(为了性能,但也因为如果顺序错误,它会变得更加明显)。然后检查您的视图顺序(检查主视图的子视图)。

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

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文